+ Post New Thread
Results 1 to 4 of 4
How do you do....it? Thread, Help with beginner script/batch file to rename Program File? in Technical; Hi folks - despite all the related topics and some time Googling, I'm still really at a loss writing a ...
  1. #1
    El_Nombre's Avatar
    Join Date
    Sep 2008
    Posts
    288
    Thank Post
    63
    Thanked 25 Times in 19 Posts
    Rep Power
    18

    Help with beginner script/batch file to rename Program File?

    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.

  2. #2
    El_Nombre's Avatar
    Join Date
    Sep 2008
    Posts
    288
    Thank Post
    63
    Thanked 25 Times in 19 Posts
    Rep Power
    18
    Also, I should probably add that if the folder "sausages.com" returns, I'd like it to be renamed.

  3. #3

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,578
    Thank Post
    1,473
    Thanked 1,227 Times in 835 Posts
    Rep Power
    753
    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...):

    Code:
    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

  4. Thanks to LosOjos from:

    El_Nombre (23rd June 2011)

  5. #4
    El_Nombre's Avatar
    Join Date
    Sep 2008
    Posts
    288
    Thank Post
    63
    Thanked 25 Times in 19 Posts
    Rep Power
    18
    Thanks LosOjos! That'll keep the sausages at bay (wait what?)

SHARE:
+ Post New Thread

Similar Threads

  1. Script to copy file and rename with YYMMDD_HHMM
    By Admiral208 in forum Scripts
    Replies: 12
    Last Post: 7th January 2011, 06:16 AM
  2. dos batch file to whs script
    By davidm in forum Windows
    Replies: 3
    Last Post: 26th March 2009, 09:37 PM
  3. File Rename Script
    By Jackd in forum How do you do....it?
    Replies: 2
    Last Post: 19th November 2008, 07:39 AM
  4. Rename a PC from a batch file - Any ideas?
    By MrLudwig in forum Windows
    Replies: 13
    Last Post: 8th December 2007, 02:40 AM
  5. Replies: 4
    Last Post: 23rd March 2006, 06:27 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
  •