Scripts Thread, File Copying in Coding and Web Development; Can anyone give me some pointers with the following?
I'm after a script that when run will detect a USB ...
-
9th May 2007, 09:53 AM #1
- Rep Power
- 0
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
-
-
IDG Tech News
-
9th May 2007, 11:03 AM #2 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.
-
-
9th May 2007, 11:58 AM #3 Re: File Copying
You could use USBDLM to make sure the drive letter is always the same then use the script by apeo.
-
-
9th May 2007, 12:00 PM #4
- Rep Power
- 0
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.
-
-
9th May 2007, 12:01 PM #5
- Rep Power
- 0
Re: File Copying
Fantastic, that should do the job nicely. I was over complicating things in my mind again.
Thanks
Mike
-
-
9th May 2007, 12:14 PM #6 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..
-
-
9th May 2007, 12:23 PM #7 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?
-
-
9th May 2007, 12:34 PM #8
- Rep Power
- 0
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?
-
-
9th May 2007, 12:57 PM #9
- Rep Power
- 0
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.
-
-
9th May 2007, 01:32 PM #10
- Rep Power
- 0
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]
-
-
9th May 2007, 01:40 PM #11 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
-
-
9th May 2007, 02:13 PM #12 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!
-
-
9th May 2007, 02:20 PM #13
- Rep Power
- 0
Re: File Copying
Now admit it. Didn't that feel good.
Sometimes you've just got to code
-
-
9th May 2007, 02:40 PM #14 Re: File Copying
lol...(panting) I'm still coming down....
-
-
9th May 2007, 02:55 PM #15 Re: File Copying
Nice solutions guys.. like it
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.
-
SHARE: 
Similar Threads
-
By strawberry in forum Windows
Replies: 2
Last Post: 20th September 2007, 09:23 AM
-
By enjay in forum Windows Vista
Replies: 4
Last Post: 6th September 2007, 02:56 PM
-
By Geoff in forum School ICT Policies
Replies: 16
Last Post: 5th June 2006, 07:52 AM
-
By tosca925 in forum Scripts
Replies: 4
Last Post: 23rd March 2006, 06:27 AM
-
By browolf in forum Windows
Replies: 1
Last Post: 18th October 2005, 04:26 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules