Jump to content

Recommended Posts

Posted

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


Posted

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)

Posted

@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.

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...