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 ...
16th September 2009, 07:12 PM #1
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..
16th September 2009, 10:44 PM #2
If you are using Windows batch commands then it will be something like;
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;
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.
16th September 2009, 11:08 PM #3
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
COPY /Y "Path to log file" "\\servername\sharename\folder\%username%"
DEL /Q "Path to log file"
17th September 2009, 08:47 AM #4
You could set the permissions to allow creation only and no deletion which would mitigate this slightly.
Originally Posted by Hacksawbob
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)
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.
Originally Posted by Hacksawbob
17th September 2009, 01:47 PM #5
THanks for the answers guys.. I knew it was something simple, just having a brain fart..
17th September 2009, 10:52 PM #6
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.
Originally Posted by OutToLunch
Sorry. It's a pet peeve !!
Thanks to ajbritton from:
OutToLunch (18th September 2009)
By PrimaryTech in forum Windows
Last Post: 13th March 2009, 09:28 AM
By projector1 in forum Scripts
Last Post: 9th March 2008, 12:15 AM
By originofsymmetry in forum Scripts
Last Post: 2nd October 2007, 12:16 PM
By Frazer in forum Scripts
Last Post: 20th June 2006, 03:53 PM
By browolf in forum Scripts
Last Post: 28th November 2005, 10:28 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)