Skip files if does not exist

I have a button which does the following:

Copy MOVE CREATEFOLDER "{d}\{s|nopath|noterm}" FILE "{d}{file$|noext}.cr2"
Copy MOVE CREATEFOLDER "{d}\{s|nopath|noterm}" FILE "{d}{file$|noext}.cr2.dop"
Copy MOVE CREATEFOLDER "{d}\{s|nopath|noterm}" FILE "{d}{file$|noext}.jpg.dop"
Copy MOVE CREATEFOLDER "{d}\{s|nopath|noterm}" FILE "{d}{file$|noext}.xmp"
Copy MOVE CREATEFOLDER "{d}\{s|nopath|noterm}" FILE "{d}{file$|noext}.wav"
Copy MOVE CREATEFOLDER "{d}\{s|nopath|noterm}" FILE "{d}{file$|noext}.jpg"

Usually, it is only 1 or 2 of those file types that work, but I keep them all because now and then I use them. Instead of creating separate buttons for each file type if and when I would need it.

Naturally, it comes up with an error when it cannot find the file types. I simply click the skip all button and it's ok. I tried to look up how to add that command to the button so I don't have to click a button. I probably don't know what to search for, but I came up blank.

Would using * for the extension and only having a single line work? Or are there sometimes files with other extensions you don't want to move?

If that isn't suitable, you can use @ifexists in a button to test if something exists, but I'd also recommend considering scripting instead, as it's usually a better choice as soon as you need conditional logic. (And it would let you put the filenames into a simple list and then loop through them once, instead of repeating each name twice, once for the test and once for the move.)

I dont think having * as an extension would work. I use the button for my photography.....

  1. folder 1 has my raw images.
  2. edit those files into another folder
  3. move certain pictures to subfolder of the edited folder (such as pano shots, or photos of me, or outtakes).
  4. need to move those same files in the raw folder as well.
  5. go into each sub-folder (of the edited folder), select files, press button and the raw files in the RAW folder in the other window get sorted out into a sub-folder with the same name as in the edited folder.

That way the raw files are in the same sub-folders as the edited folder. It is a big time saver as i use to do it manually before. I believe you, or someone here gave me those commands and i just added extra ones for the diff extensions as needed over the years.

I have no knowledge of scripting, so unless you or someone else here would be willing to do it for me, I will have to keep it the way it is at the moment.

Where does the @ifexists go? i tried adding it as line 2, but it did nothing. The script ran the same way as before. If I add it to each line before the copy then nothing at all happens when I click the button.

It would do exactly the same thing as your existing button, unless there were files with the same name but different extensions (extensions not included in your existing button) which you didn't want to move.

If files with other extensions are a problem, you could use .(cr2|cr2.dop|jpg.dop|xmp|wav|jpg) as the extension wildcard to do exactly the same as your existing button:

Copy MOVE CREATEFOLDER "{d}{s|nopath|noterm}" FILE "{d}{file$|noext}.(cr2|cr2.dop|jpg.dop|xmp|wav|jpg)"

I think that should solve things by itself.

Thanks. That works wonderfully :slight_smile:

1 Like

This little button works wonders for me.

Right now, I go into the folder in question, select the files and click the button and it does what it does.

How would this be modified so that I can select the folder and then it does the same thing.


  • c:\folder1\test


  • c:\folder1

The way it works now is I go into c:\folder1\test select the files and then it creates a folder "test" in the target and moves the files into it.

What I would like to do is to select folder "test" instead of the files inside of it and then it does the rest the same. Or perhaps select multiple folders and do it. How would that be done?




in your command.

It does not seem to work. I get this error when I run it:


That isn't the whole command. Use the new FILE=... argument to replace the FILE=... argument in the old command.

1 Like

I tried that...

Copy MOVE CREATEFOLDER "{d}{s|nopath|noterm}" FILE "{filepath}*.(cr2|cr2.dop|jpg.dop|xmp|wav|jpg)" "{d}{file$|noext}.(cr2|cr2.dop|jpg.dop|xmp|wav|jpg)"

What happens:

  • select folder "test" hit the button
  • moves files from c:\folder\test to c:\folder1\folder

By selecting c:\folder\test it should find the same files within c:\folder1, create folder test and move the files from folder1 into folder1\test

My original request I noticed a typo.. the source should have been c:\folder\test

What lxp showed has an equal sign after FILE. What you said you tried doesn't.

I don't know if that makes any difference or not.

I haven't thought on this thread,
but I can see that you have two clauses after FILE instead of one.
FILE expects one set of quotes.

This would require a script.

No, = is optional. I recommend it for clarity, though.

FILE can take more than one file. Something like this works perfectly fine:

Copy MOVE TO=D:\Folder FILE D:\file1.txt D:\file2.txt!Documents/Copy.htm