MSFN Forum: Copy File and Rename and more - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Copy File and Rename and more Need your help building a Script Rate Topic: -----

#1 User is offline   AndrewTrevayne 

  • Group: Members
  • Posts: 2
  • Joined: 05-October 11
  • OS:none specified
  • Country: Country Flag

Posted 05 October 2011 - 11:47 PM

Hi Everyone,
Let me introduce myself, My name is Andrew and I am quite new to this forum.
I came to know it while searching for a solution to my project and I hope you guys could help me figure out a way to do it.

Here are some of the basic Details:

Folder Structure
C:\Confidential
Under this Parent folders are 2 Sub folders

C:\Confidential\ABC-11
Prod_Oct_03_2011
Oct_03_2011

C:\Confidential\ABC-22
Prod_Oct_03_2011
Oct_03_2011


There are 2 Folder within the Parent Folder Confidential, these folders are ABC-11 and ABC-22.
* Inside ABC-11 I need to copy the folders Prod_Oct_03_2011 and folder Oct_03_2011 on the same folder (ABC-11) Except that it will be renamed to the date which I need to Input (some sort of ask date input at the beginning of the Script)
* Inside ABC-22 I need to copy the folders Prod_Oct_03_2011 and folder Oct_03_2011 on the same folder (ABC-12) Except that it will be renamed to the date which I need to Input (some sort of ask date input at the beginning of the Script)

On top of this I have this text file called EditData.txt
This file resides on all the 4 folders to be copied

ABC-11\Prod_Oct_03_2011 and Oct_03_2011
ABC-22\Prod_Oct_03_2011 and Oct_03_2011

The file EditData.txt contains one line which is the date (On this format ->Oct 03 2011)
, Which I also need to update to the date that I just inputted.

This process is quite complicated and very tedious doing it manually (On a weekly basis).
Could you suggest a way to automate it? I was looking at possible doing a VBScript for this but Im a novice when it comes to scripting.
I did came across some script below (and edited it) but I dont think it does anything.

Dim FSO

Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFolder "C:\Confidential\ABC-11", "C:\Confidential"
FSO.CopyFolder "C:\Confidential\ABC-22", "C:\Confidential"

Set FSO = nothing


The Process that I would like to achieve is:
1.) I will be prompted to ask for a date
2.) Copy the Folders and Rename the Folders (Name will be based on the date I just inputted)
3.) The Line on the file EditData.txt will be changed (Line will be based on the date I inputted MMM DD YYYY)

Is this possible? Appreciate if you could help me on this little project. Thank you in advance.

Cheers,
Andrew


#2 User is online   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,351
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 06 October 2011 - 02:01 AM

If you need the user input only to get the date format that you specified
you can do it with VBS scripting.
Example Code Below Produces Month_Date_Year
Dim Dt :Dt = Day(Date)
 If Len(Dt) = 1 Then Dt = "0" & Dt 
WScript.Echo MonthName(Month(Date),True) & "_" & _
              Dt & "_" & Year(Date)



#3 User is offline   AndrewTrevayne 

  • Group: Members
  • Posts: 2
  • Joined: 05-October 11
  • OS:none specified
  • Country: Country Flag

Posted 12 October 2011 - 02:20 AM

@gunsmokingman
Thank you sir. But Im really a noob and not sure how to use the script that you just gave. But again thanks.

Any other inputs? Appreciate your help. Thanks.

#4 User is online   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,351
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 12 October 2011 - 11:54 AM

The first code would replace this code to get the date format.
Dim Act   :Set Act = CreateObject("Wscript.Shell")
Dim Info  :
'-> Loop To Get User Responce
  Do Until Info > ""
'-> User Input
   Info = InputBox("Type In The Date Format Month/Date/Year" & _
    "Or Just Type Exit Or Quit To Do Nothing.")  
'-> User Cancel
  If InStr(1,Info,"quit" ,1) Or InStr(1,Info,"exit" ,1) Then
    Act.Popup "User Cancel Script, Preparing To Close", 4,"User Input",4128
    WScript.Quit 
  End If 
'-> Process User Input
   If Not Info = "" Then 
    Act.Popup "User Input = " & Info, 4,"User Input",4128
    Exit Do
   End If 
  Loop



Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy