Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Script Writing

  • 14-07-2008 11:47am
    #1
    Registered Users, Registered Users 2 Posts: 268 ✭✭


    Hi, I need help creating a script file to move files from one folder to another.
    Basically i have a folder with 100000 docs in it, Folder 1, and I have a list of 50000 of those that need to be moved to different folder, Folder 2. I havent a clue how to write scripts so any help would be really appreciated.

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 2,534 ✭✭✭FruitLover


    OS?
    Language?
    Differentiating criteria?

    Help us to help you.


  • Registered Users, Registered Users 2 Posts: 268 ✭✭LillyVanilli


    Oh sorry, see I told you I didnt have a clue. Windows 2003 server. I was hoping to run it from a command prompt is that possible? The differentiating criteria are the names of the files, does that make sense?


  • Registered Users, Registered Users 2 Posts: 1,306 ✭✭✭carveone


    Is your list of files in text format? Like one file name per line? There are multiple different ways to do what you are asking - in vbscript, in shell batch or hell even in awk (if you download a version for windows). The reason I ask is that if the text file is complex - like CSV format (Excel) - then you'll have to take a bit more care in processing it before acting on the results.


  • Registered Users, Registered Users 2 Posts: 268 ✭✭LillyVanilli


    I have the file in two formats, .txt & .csv. One file name per line


  • Registered Users, Registered Users 2 Posts: 1,306 ✭✭✭carveone


    Easier than you think then.

    for /F %i in (filelist.txt) do move "%i" "folder2"

    Um. There might be issues with filenames with spaces in them so I'll go off now and try it out and get back to you!


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 268 ✭✭LillyVanilli


    No spaces so that should be fine, Ill try it now. Thanks a million


  • Registered Users, Registered Users 2 Posts: 1,306 ✭✭✭carveone


    Oh yeah! There are definately issues with spaces!!

    Ahem. Try again:

    for /F "delims=:" %i in (filelist.txt) do move "%i" "folder2"

    That sets the token delimiter from a space/tab to a colon, which cannot appear in any valid filename. Solves the problem. Use the quoting I've shown to make sure that the move command doesn't get confused with spaced filenames. If you've any doubts, put the command "@echo" in between the do and the move to see what command would be executed...

    for /F "delims=:" %i in (filelist.txt) do @echo move "%i" "folder2"

    Hell you could then redirect this to a batch file like this

    for /F "delims=:" %i in (filelist.txt) do @echo move "%i" "folder2" > go.bat

    and then type go to process the whole list....

    Edit: Oh yeah, of course all this is at a cmd prompt (Start/Run/cmd.exe) and in the right directory!


  • Registered Users, Registered Users 2 Posts: 268 ✭✭LillyVanilli


    Yeah ive no spaces in the file names so it works perfectly.

    Thanks a million, much quicker than trying to move thousands of files manually.

    Cheers


Advertisement