-
File Copying
Can anyone give me some pointers with the following?
I'm after a script that when run will detect a USB flash drive and copy a file off of it to another location.
I've got 32 flash drives to copy a file off and I don't fancy doing it all manual so a plug in and click would be nice lazy way of doing things!
TIA
Mike
-
Re: File Copying
From the sounds of it you dont need a script to detect the presence of a USB Drive as the drive should have the same drive letter each time so long as you unplug one before you plug in another. With that in mind a simple bat/cmd script should suffice... something like:
Code:
copy [Driveletter]:\*.* c:\temp /y
Where Driveletter is the drive letter of the flash drive.
-
Re: File Copying
You could use USBDLM to make sure the drive letter is always the same then use the script by apeo.
-
Re: File Copying
Ah but you will end up with one file but not 32.
You will will probably have to have use VBS to end some timestamp pre/suffix.
-
Re: File Copying
Fantastic, that should do the job nicely. I was over complicating things in my mind again.
Thanks
Mike
-
Re: File Copying
@ajbritton: am i wrong in thinking that removable drives are associated with the first avaible drive letter and unless you have drive that change their drive letter or you plug in more devices, then the drive letter should remain the same.... shouldnt it?
@NetworkGeezer: Well he did say he was going to plug them in 1 at a time..
-
Re: File Copying
Wonder how much time you would actually save by using the script and doing it manually. That is manually you would plug in, ctrl+a (in usb drive), copy and paste in desired location... and automated(ish) plug in and double click bat/cmd. Would think its only a fraction quicker.
Perhaps you could plug in a few at a time and use a script to copy all of em at once or sequentially to desired location.. would be less tedious and possibly quicker?
-
Re: File Copying
You're right and that thought did occur to me but if preventing errors is a concern then automation is the way to go.
Can I ask what thisu collecting for Kwyjibo? Are you collecting work from student laptops?
-
Re: File Copying
Reports from teachers, they need to be backed up so was just looking looking for a quick and easy way of doing it.
-
Re: File Copying
OK so this kind of thing would have to be done periodically so scripting would not be a complete waste of time.
The really geeky thing to do would be to be generate the destination file name by indetifying the teacher from the GUID of the USB drive.
For now you jstu have to rely on command line arguments to the script name.
Code:
cscript teacher-report-back-script.vbs <teacher-name> [USB-drive letter]
-
Re: File Copying
You could prompt for a name either each time the script is executed (assuming you run it once per USB drive), or each time a new file is detected. The script could then use the supplied name to either create a subfolder, or to modify the filename accordingly.
Thinking further, how about this...
Script checks for an INI file on the root of the USB drive (eg OWNER.INI)
- If the INI file is found, the script pulls the teachers name out of it
- If the INI file is NOT found, the script prompts for the owner's name and then stores it in OWNER.INI on the drive.
The script now knows who the drive belongs to and will remember it for next time.
The script now copies the required file, modifying the name to be something like JoeBlogss_ReportDoc.doc
-
Re: File Copying
Attached is a hastily cobbled together AutoIt script. It's not compiled so AutoIt will need installing wherever you need to run it.
Basically, it does what I suggested in my previous post. Feel free to use or adapt it in any way you see fit. There is plenty of room for improvement here!
-
Re: File Copying
Now admit it. Didn't that feel good.
Sometimes you've just got to code :)
-
Re: File Copying
lol...(panting) I'm still coming down....
-
Re: File Copying
Nice solutions guys.. like it :D
I would be tempted to just say to the teachers, 'Here is a location on the shared drive Ive created for you, copy all your work there from your usb stick or it wont get backed up' :twisted: Also begs the question why arent these files in their home directory where it would be backed up anyway.