+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
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 ...
  1. #1

    Join Date
    Apr 2007
    Location
    Kent
    Posts
    9
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    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

  2. #2
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    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.

  3. #3
    ajbritton's Avatar
    Join Date
    Jul 2005
    Location
    Wandsworth
    Posts
    1,632
    Thank Post
    23
    Thanked 75 Times in 45 Posts
    Rep Power
    34

    Re: File Copying

    You could use USBDLM to make sure the drive letter is always the same then use the script by apeo.

  4. #4

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    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.

  5. #5

    Join Date
    Apr 2007
    Location
    Kent
    Posts
    9
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Re: File Copying

    Fantastic, that should do the job nicely. I was over complicating things in my mind again.

    Thanks

    Mike

  6. #6
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    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..

  7. #7
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    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?

  8. #8

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    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?

  9. #9

    Join Date
    Apr 2007
    Location
    Kent
    Posts
    9
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    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.

  10. #10

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    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]

  11. #11
    ajbritton's Avatar
    Join Date
    Jul 2005
    Location
    Wandsworth
    Posts
    1,632
    Thank Post
    23
    Thanked 75 Times in 45 Posts
    Rep Power
    34

    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

  12. #12
    ajbritton's Avatar
    Join Date
    Jul 2005
    Location
    Wandsworth
    Posts
    1,632
    Thank Post
    23
    Thanked 75 Times in 45 Posts
    Rep Power
    34

    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!

  13. #13

    Join Date
    Feb 2006
    Posts
    1,187
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Re: File Copying

    Now admit it. Didn't that feel good.

    Sometimes you've just got to code

  14. #14
    ajbritton's Avatar
    Join Date
    Jul 2005
    Location
    Wandsworth
    Posts
    1,632
    Thank Post
    23
    Thanked 75 Times in 45 Posts
    Rep Power
    34

    Re: File Copying

    lol...(panting) I'm still coming down....

  15. #15
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    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:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. copying a file without admin
    By strawberry in forum Windows
    Replies: 2
    Last Post: 20th September 2007, 10:23 AM
  2. Copying CDs with Vista
    By enjay in forum Windows Vista
    Replies: 4
    Last Post: 6th September 2007, 03:56 PM
  3. Copying music CDs
    By Geoff in forum School ICT Policies
    Replies: 16
    Last Post: 5th June 2006, 08:52 AM
  4. Replies: 4
    Last Post: 23rd March 2006, 07:27 AM
  5. copying a file at logon
    By browolf in forum Windows
    Replies: 1
    Last Post: 18th October 2005, 05: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
  •