DonationCoder.com Software > Coding Snacks
Script/batch file that copies two files from a drive(usb) to a location
foolios:
Script/batch file that copies two files from a drive(usb) to a location within a windows directory.
If I had a thumb drive and I wanted to make two files go to two different locations by just running the script.
Would the dos commands like:
copy f:\data\data.exe c:\windows\system32\data
copy f:\data\pic.jpg C:\Documents and Settings\Administrator\Desktop
work in a bat file?
I don't have a usb drive to test atm. Thanks so much in advance.
cranioscopical:
Yes
foolios:
Ok, this is what I have then so far.
copy C:\TestCopy\myicon.ico C:\TestCopy\datafolder\
copy C:\TestCopy\myieshortcut C:\TestCopy\datafolder\
The problem is that the second line is a shortcut, an internet shortcut. I don't know the file extension to it as it's not showing even with file extension view enabled for folder options.
Is there an extension?
Also, how can I shorten the two lines? Is it possible to use one copy command to perform both copies?
Thanks for replying.
wolf.b:
Is there an extension?
--- End quote ---
maybe yes, maybe no.
One of many ways to find out is checking with a different filemanager than explorer. I suggest the DOS prompt like this:
Start>Run>cmd.exe (press enter)
type cd C:\TestCopy (press enter)
type dir myieshortcut.* (press enter)
Look at the output of the dir command.
alternatively you could try and open the file in notepad like this:
Start>Run>cmd.exe (press enter)
type cd C:\TestCopy (press enter)
type notepad myieshortcut (press enter)
if notepad opens an empty file, then your original file has a still hidden extension.
the command for could be what you are looking for:
--- ---@echo off
for %%f in (myicon.ico, myieshortcut) do copy C:\TestCopy\%%f C:\TestCopy\datafolder
Please post again if you need more hints or alternatives.
Greeting
Wolf
foolios:
You are the man my friend. It displayed the file extension. Thank you so much.
@echo off
for %%f in (myicon.ico, myieshortcut) do copy C:\TestCopy\%%f C:\TestCopy\datafolder
What does that line do besides copy? what is for %%f in mean?
and the line: @echo off, that removes extra spaces right?
thanks again
EDIT: it looks to me like:
for %%f in (myicon.ico, myieshortcut)
sets a variable with those two file names in it. If so, that 's just awesome!
EDIT:
for the location:
C:\Documents and Settings\All Users\Desktop
I seem to remember that spaces couldn't be used, maybe that's why my file isn't copying to the desktop when I try it.
Am I to put % or something in places where a directory name is a space when dealing with the windows file system?
THanks
EDIT: Yes, that's most definitely the problem I think. And I don't think % is the answer for spaces. I get the error incorrect syntax on the part where I am trying to copy to a directory with spaces.
Navigation
[0] Message Index
[#] Next page
Go to full version