Simple Button - expanded

Here ...

Windows Batch-File to JScript - #2 by lxp - Help & Support - Directory Opus Resource Centre

... @lxp gave me the start of my current button, which now deals not only with the actors, but also with the rest of the crew (director, writer...) (The button helps me to easily move info files into their respective folders.)

	<function type="normal">
		<instruction>Copy      FILE=/down\*.jpg   TO=/pix-pers</instruction>
		<instruction>Copy      FILE=/down\*.md    TO=/actor</instruction>
		<instruction />
		<instruction>Copy MOVE FILE=/down\*.jpg   TO=/preTrash</instruction>
		<instruction>Copy MOVE FILE=/down\*.md    TO=/preTrash</instruction>
	</function>

The basic function is

  1. Copy images from "/down" (download folder, alias) to
    "/pix-pers" (image folder, alias)

This action is the same for all cast and crew. The images will end up in one image folder.

  1. Copy "*.md" files from "/down" (download folder, alias) to
    "actors" (actors folder, alias)

This action moves *.md files to their respective folders, so it's a copy to different targets (actor, director, writer ...).

  1. Make a temporary backup of all files in "/preTrash
    This action moves the files to a temporary folder called "/preTrash", so they're still there until I delete "/preTrash" manually.

In the button step #3 is repeated verbatim for
crew + cast

  • actor
  • director
  • writer
  • camera
  • composer
  • producer
  • other
```
Copy MOVE FILE=/down\*.jpg   TO=/preTrash
Copy MOVE FILE=/down\*.md    TO=/preTrash
```

What I want to do is put these 2 lines into a function and replace them in their respective (sub)buttons with a function call:

allTempFolder()

So the function might look like this:

function allTempFolder() {
    Copy MOVE FILE=/down\*.jpg   TO=/preTrash
    Copy MOVE FILE=/down\*.md    TO=/preTrash
    return
}

(I have attended a 3,5 hours online course on JavaScript. That's it)


I have not the foggiest idea how to do this...Please help :smiley:


Here is the code for the complete button. Via copypaste I expanded it 6 times and exchanged the actual folder paths with aliases.


<?xml version="1.0"?>
<button backcol="none" display="icon" label_pos="right" textcol="none" type="menu_button">
	<label>Cast &amp;&amp; Crew</label>
	<tip>Moving info files to appropriate folder | keeping a copy in preTrash</tip>
	<icon1>/button\nobody 02.jpg,0</icon1>
	<icon2>/button\nobody 02 - inverted.jpg,0</icon2>
	<function type="normal">
		<instruction>Copy      FILE=/down\*.jpg   TO=/pix-pers</instruction>
		<instruction>Copy      FILE=/down\*.md    TO=/actor</instruction>
		<instruction />
		<instruction>Copy MOVE FILE=/down\*.jpg   TO=/preTrash</instruction>
		<instruction>Copy MOVE FILE=/down\*.md    TO=/preTrash</instruction>
	</function>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Director</label>
		<tip>Create New Director</tip>
		<icon1>/button\director.png,0</icon1>
		<function type="normal">
			<instruction>Copy      FILE=/down\*.jpg   TO=/pix-pers</instruction>
			<instruction>Copy      FILE=/down\*.md    TO=/director</instruction>
			<instruction />
			<instruction>Copy MOVE FILE=/down\*.jpg   TO=/preTrash</instruction>
			<instruction>Copy MOVE FILE=/down\*.md    TO=/preTrash</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Writer</label>
		<tip>Create New Writer</tip>
		<icon1>/button\writer.png,0</icon1>
		<function type="normal">
			<instruction>Copy      FILE=/down\*.jpg   TO=/pix-pers</instruction>
			<instruction>Copy      FILE=/down\*.md    TO=/writer</instruction>
			<instruction />
			<instruction>Copy MOVE FILE=/down\*.jpg   TO=/preTrash</instruction>
			<instruction>Copy MOVE FILE=/down\*.md    TO=/preTrash</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Camera</label>
		<tip>New Camera</tip>
		<icon1>/button\cinematographer.png,0</icon1>
		<function type="normal">
			<instruction>Copy      FILE=/down\*.jpg   TO=/pix-pers</instruction>
			<instruction>Copy      FILE=/down\*.md    TO=/camera</instruction>
			<instruction />
			<instruction>Copy MOVE FILE=/down\*.jpg   TO=/preTrash</instruction>
			<instruction>Copy MOVE FILE=/down\*.md    TO=/preTrash</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Composer</label>
		<tip>Create New Composer</tip>
		<icon1>/button\composer j.jpg,0</icon1>
		<function type="normal">
			<instruction>Copy      FILE=/down\*.jpg   TO=/pix-pers</instruction>
			<instruction>Copy      FILE=/down\*.md    TO=/music</instruction>
			<instruction />
			<instruction>Copy MOVE FILE=/down\*.jpg   TO=/preTrash</instruction>
			<instruction>Copy MOVE FILE=/down\*.md    TO=/preTrash</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Producer</label>
		<tip>New Producer</tip>
		<icon1>/button\producer.png,0</icon1>
		<function type="normal">
			<instruction>Copy      FILE=/down\*.jpg   TO=/pix-pers</instruction>
			<instruction>Copy      FILE=/down\*.md    TO=/producer</instruction>
			<instruction />
			<instruction>Copy MOVE FILE=/down\*.jpg   TO=/preTrash</instruction>
			<instruction>Copy MOVE FILE=/down\*.md    TO=/preTrash</instruction>
		</function>
	</button>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Other</label>
		<tip>New Other</tip>
		<icon1>/button\000.png,0</icon1>
		<function type="normal">
			<instruction>Copy      FILE=/down\*.jpg   TO=/pix-pers</instruction>
			<instruction>Copy      FILE=/down\*.md    TO=/other</instruction>
			<instruction />
			<instruction>Copy MOVE FILE=/down\*.jpg   TO=/preTrash</instruction>
			<instruction>Copy MOVE FILE=/down\*.md    TO=/preTrash</instruction>
		</function>
	</button>
</button>

No need for script. Just put the two lines into a User Command.

So here's what I did:

  1. Created a button
  2. Put the lines into it.
  3. Much to my surprise - it worked

Here it is

<?xml version="1.0"?>
<button backcol="none" display="icon" label_pos="right" textcol="none">
	<label>off2trash</label>
	<icon1>#newcommand</icon1>
	<function type="normal">
		<instruction>Copy MOVE FILE=/down\*.jpg   TO=/preTrash</instruction>
		<instruction>Copy MOVE FILE=/down\*.md    TO=/preTrash</instruction>
	</function>
</button>

How do I call/invoke that button/user command from the first button ("Cast & Crew")?
What is a user command?

I've searched the forum and the manual and get a list of examples. The only thing I understand about the really simple ones is that the commands somehow belong in a button.

I feel like someone invited me to a party but gave me the wrong address....


Edit (2023-08-16 151801)
Found it :slight_smile: The search term would be "user-defined command" (with the "-" sign)
Customize -> user commands

Thanks - will be back with news ...

.

Thank you very much :smiley: I happily created my first user-command :wink: and saved 7 lines in my button. At the moment my head is spinning with the previously unknown concept of "user-commands".

I will now apply for a promotion to probationary file shoveler 3rd grade

1 Like

Champagne for everyone! :champagne:

1 Like