Solved Copy certain files when the filename exist in another folder

May 1, 2012 at 08:36:20
Specs: Windows 7
I want to create a script to do the following.
I have .cr2 files in a folder called raw.
I have .jpg files in a folder called jpg.
I have an empty folder called selected.
I want the script to read the file names in the jpg folder and copy the same file names from the raw folder to the selected folder.

I am sure this is easy but I am new to scripts.


See More: Copy certain files when the filename exist in another folder

Report •


#1
May 1, 2012 at 11:23:35
✔ Best Answer
for %%a in (jpg\*.jpg) do copy "raw\%%~Na.raw" selected\

How To Ask Questions The Smart Way


Report •

#2
May 1, 2012 at 11:43:54
for %%a in (jpg\*.jpg) do copy "raw\%%~Na.raw" selected\

Did not work for me. But it could be me. Let me make sure I am executing the script correctly. I copied the script into notepad and saved it as a .vbs file. I then ran the .vbs file and got an error Line 1 Char 5 Invalid Character. Is this the correct way to run the script? All of the folders mentioned above and the .vbs file are in the c:/ directory.


Report •

#3
May 1, 2012 at 11:57:47
It's a batch file (.cmd), not a VBScript (.vbs).

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
May 1, 2012 at 12:19:32
Thank you for clearing that up for me. It worked perfectly! THANK YOU so very much for your skills.

Report •


Ask Question