El_Nombre Posted June 23, 2011 Posted June 23, 2011 Hi folks - despite all the related topics and some time Googling, I'm still really at a loss writing a script (or maybe even a batch file?) to rename a folder on client machines. I'd like to set a startup script through GP to rename a folder (eg C:\Program Files\sausages) if it finds on the client machine. I tried (please don't laugh... too hard...) the following: if exist "c:\Program Files\sausages.gone" goto :EOF if exist "c:\Program Files\sausages.com" rename "c:\Program Files\sausages.com" sausages.gone @echo Job Run Literally no idea what I'm doing. And do I go with vbs script or batch file for this you think? Any help greatly appreciated. And no there's no sausages on the network.
El_Nombre Posted June 23, 2011 Author Posted June 23, 2011 Also, I should probably add that if the folder "sausages.com" returns, I'd like it to be renamed.
LosOjos Posted June 23, 2011 Posted June 23, 2011 VBS is probably easier from a debugging POV, although really it's personal preference. This should do the trick (obviously replace the paths, unless you really do have sausages on your network...): Option Explicit Const sFolder = "C:\Sausages" 'Source folder Const dFolder = "C:\walls" 'Destination folder Dim FSO 'File System Object Set FSO = CreateObject("Scripting.FileSystemObject") If FSO.FolderExists(sFolder) Then FSO.MoveFolder sFolder, dFolder Set FSO = Nothing Should all be self explanatory, but just in case, 'sFolder' is the folder you're checking the existence of, 'dFolder' is what the folder will be renamed to if it does indeed exist EDIT: for re-usability, this script could be quite easily adapted to take command line arguments for source and destination folders, let me know if you'd like to see that script 1
El_Nombre Posted June 23, 2011 Author Posted June 23, 2011 Thanks LosOjos! That'll keep the sausages at bay (wait what?)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now