+ Post New Thread
Results 1 to 6 of 6
Scripts Thread, Script to Copy files into into individual folders? in Coding and Web Development; I have 400+ PC's that all have some log files i need to move off.. I want to make a ...
  1. #1
    dahhunter's Avatar
    Join Date
    Jun 2009
    Location
    Langley, BC
    Posts
    3
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Script to Copy files into into individual folders?

    I have 400+ PC's that all have some log files i need to move off..

    I want to make a script/Batch file that will do the following when the user logs in:

    Creates a Folder on a network share with the individual users name
    Moves the Log files from the Local PC to the create User folder
    Deletes the Local Files after the move

    Sounds simple enough..

    Its the Creating a folder with the user name i cant figure out..

    Im hoping its something simple.. Im trying to do this all with a batch file ATM..

    THanks

  2. #2
    ajbritton's Avatar
    Join Date
    Jul 2005
    Location
    Wandsworth
    Posts
    1,632
    Thank Post
    23
    Thanked 75 Times in 45 Posts
    Rep Power
    34
    If you are using Windows batch commands then it will be something like;

    Code:
    MD "\\servername\sharename\folder\%username%"
    This should work as long as the username does not contain any characters that are invalid in folder names.

    Without any error checking, the script will look something like;

    Code:
    MD "\\servername\sharename\folder\%username%"
    COPY "Path to log file" "\\servername\sharename\folder\%username%"
    DEL "Path to log file"
    Last edited by ajbritton; 16th September 2009 at 10:47 PM.

  3. #3
    Hacksawbob's Avatar
    Join Date
    Apr 2008
    Location
    North West UK
    Posts
    192
    Thank Post
    13
    Thanked 20 Times in 16 Posts
    Blog Entries
    2
    Rep Power
    18
    MD "\\servername\sharename\folder\%username%"
    COPY /Y "Path to log file" "\\servername\sharename\folder\%username%"
    DEL /Q "Path to log file"
    will possibly overwrite log from previous login if the name is the same the user would need to have write permissions to the share and sub folders of course! which if they knew they could potentially access and delete

  4. #4

    Join Date
    Feb 2006
    Location
    Derbyshire
    Posts
    1,381
    Thank Post
    181
    Thanked 211 Times in 171 Posts
    Rep Power
    65
    Quote Originally Posted by Hacksawbob View Post
    will possibly overwrite log from previous login if the name is the same the user would need to have write permissions to the share and sub folders of course!
    You could set the permissions to allow creation only and no deletion which would mitigate this slightly.

    To avoid overwriting log files, you could always tag the date onto the end of them -

    copy C:\blah\blah\log.txt \\server\blah\logs\%username%%date:/=-%.txt

    or if you wanted to get clever with it,

    copy C:\blah\blah\log.txt \\server\blah\logs\server\%date:~6,4%-%date:~3,2%-%date:~0,2%-%username%.txt

    which will give you the date at the start of the filename in a nice sortable order (YYYY-MM-DD)

    Quote Originally Posted by Hacksawbob View Post
    which if they knew they could potentially access and delete
    There's an awful lot of shares like that on the network which can't be avoided though - things like the Promissor exam software etc which demand a shared folder with full permissions.

  5. #5
    dahhunter's Avatar
    Join Date
    Jun 2009
    Location
    Langley, BC
    Posts
    3
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    THanks for the answers guys.. I knew it was something simple, just having a brain fart..

  6. #6
    ajbritton's Avatar
    Join Date
    Jul 2005
    Location
    Wandsworth
    Posts
    1,632
    Thank Post
    23
    Thanked 75 Times in 45 Posts
    Rep Power
    34
    Quote Originally Posted by OutToLunch View Post
    There's an awful lot of shares like that on the network which can't be avoided though - things like the Promissor exam software etc which demand a shared folder with full permissions.
    I really HATE it when suppliers/support staff ask you to set up Full Control when they obviously don't even understand what it means or implies. I have never seen any justification for Full Control for any application.

    Sorry. It's a pet peeve !!

  7. Thanks to ajbritton from:

    OutToLunch (18th September 2009)

SHARE:
+ Post New Thread

Similar Threads

  1. Batch copy files and folders up one level
    By PrimaryTech in forum Windows
    Replies: 0
    Last Post: 13th March 2009, 09:28 AM
  2. Replies: 5
    Last Post: 9th March 2008, 12:15 AM
  3. Mass Copy of Files and Folders
    By originofsymmetry in forum Scripts
    Replies: 6
    Last Post: 2nd October 2007, 12:16 PM
  4. Replies: 19
    Last Post: 20th June 2006, 03:53 PM
  5. script to copy files to machines
    By browolf in forum Scripts
    Replies: 1
    Last Post: 28th November 2005, 10:28 AM

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
  •