Copy file is Two files Exsist

May 5, 2011 at 02:41:07
Specs: Windows 7, Quad Core i7, 12gb ram
Hi,

I am trying to copy files from one folder to another, however I only want to copy the files if two files exsist with the same file name. so we have:

file1.ord
file1.occ
file2.ord
file3.ord
file3.occ

these are the files in the folder I only want it copying file1 and file 3 because they have two files with that file name and then leave file2 in the folder.

has anyone got a way of doing this? if its not possible in vbscript can you suggest another script?

Thanks,
Simon


See More: Copy file is Two files Exsist

Report •


#1
May 5, 2011 at 07:28:11
@echo off
pushd Source_Folder
for %%j in (*.ord) do if exist "%%~nj.occ" move "%%~nj.*" "Target_Folder"
popd

The above script moves both .ord and .occ files to the destination folder if both files exist in the source folder by browsing for .ord extension.

If you gave the info requested instead of duplicating your post maybe the solution would be more effective.


Report •
Related Solutions


Ask Question