In our root directory for example D: We have numerous Folders which store Excel Files by category. How to write a macro to search each folder from the root directory, move or copy the Excel files to an external hard disc or an USB drive without using the manually move or copy and paste process.
I think macro can ensure completeness in the excel files move and copy process...
Hi David,
Use xcopy from the Command Prompt - much easier as it already exists.
I assume you are using Windows. Click on the Start/Windows button in the bottom left of the screen. Type cmd and the Command Prompt app should be shown. Click on it to open a Command Prompt window.
Type xcopy /? to see the help info for xcopy.
To copy files from D: and all subfolders, to the U: drive, you'll want to use a command like this
xcopy d:*.xls* u: /s /c /i /r /y
Double check the command switches to make sure they do what you want.
Regards
Phil
Thanks Philip will attempt to use this command!
Can we use delete command permanent delete all after files copy to external hard disk?
It depends on what files you want to delete. If it is ALL files of a certain type or name you can use del *.XLS* /s but that will delete ALL files that end in .xls*
Be careful to understand what you are doing before running the del command.
Phil
Thanks I already tried xcopy command and confirmed successful, thanks again all xls files or similar type copy to the external hard disc.
Now I can try the delete command
BTW can you elaborate what is /s/c/i/r/y meaning in the command
for /s - I guess subfolder
Hi David,
If you type xcopy /? in the Command Prompt you get all the help info for xcopy that tells you what the switches do.
/s Copy directories and sub-directories except empty ones
/c Continue copying if an error occurs
/i If the destination does not exist and copying more than one file, assume the destination is a directory
/r Overwrite read only files
/y Do not prompt to confirm overwriting of an existing fie in the destination.
Cheers
Phil
Got it all , Philip, deep thanks again the guidance and useful remind of the DOS command skills.
No worries David. I remember reading a manual on the DOS Prompt from cover to cover. I used to write a lot of batch files for things like remote installations of Windows. The commands are still very useful.
Phil
Do really appreciate if you can share the Batch files with us, despite it departs a bit from this Forum...
It was 20+ years ago. I don't have them any more
Wow, time flies, thanks for sharing your precious experience!
It certainly does.