I hope to experiment more with these suggestions tonight or tomorrow. I'll post my results thereafter. Thank you. Fred
DOS Copy Command
I want to copy all files in a directory that end in "*1.zip" to the same name but ending in "*7.zip"
I tried (but it didn't work)
copy c:\users\fred\*1.zip c:\users\fred\*7.zip
Suggestions?
Thanks
Windows development | Windows API - Win32
4 answers
Sort by: Most helpful
-
Viorel 127K Reputation points2021-04-25T20:45:10.637+00:00 Try executing a .BAT file containing something like this:
@echo off for %%f in (c:\users\fred\*1.zip) do ( call :sub "%%f" ) goto :end :sub set p=%~1 set p=%p:~0,-5% set p=%p%7.zip echo copy %1 "%p%" :endIt displays the generated "copy" commands. Remove "echo" to copy the files effectively.
-
WayneAKing 4,936 Reputation points2021-04-24T22:30:31.197+00:00 [repost as my first try disappeared]
Unfortunately, the filenames are various lengths
If all else fails, you could of course use a rather
"cludgy" approach such as this in a bat file:copy c:\users\fred\?1.zip c:\users\fred\?7*
copy c:\users\fred\??1.zip c:\users\fred\??7*
copy c:\users\fred\???1.zip c:\users\fred\???7*
copy c:\users\fred\????1.zip c:\users\fred\????7*
copy c:\users\fred\?????1.zip c:\users\fred\?????7*
copy c:\users\fred\??????1.zip c:\users\fred\??????7*
etc.- Wayne
-
WayneAKing 4,936 Reputation points2021-04-24T19:38:18.52+00:00 Do all of the files to be copied have the same length
file names? If so, you can do this (example assumes
a five-character name preceding the 1):copy ?????1.zip ?????7*
copy c:\users\fred\?????1.zip c:\users\fred\?????7*
- Wayne