I'm trying to access files in a directory that gets a new name daily during a backup job.
Example of folder name E:\ServerName\Backup 2015-10-28 223032
I tried using wildcards with ChangeDirectory> like you can in a command prompt E:\>cd Serv*\Backu*,
Line 59: Error: Directory E:\>cd ServerName\Backu* Does Not Exist.
Anyone know of a creative way to drill down into this directory?
Changing to a dynamically named directory
Moderators: JRL, Dorian (MJT support)
-
- Pro Scripter
- Posts: 132
- Joined: Mon Dec 22, 2008 4:56 pm
- Location: St Augustine FL
Changing to a dynamically named directory
Thank you in advance for all your help
Gil
Gil
Re: Changing to a dynamically named directory
The following code helps you enumerate folders with names Backup yyyy-mm-dd hhmmss:gchichester wrote:I'm trying to access files in a directory that gets a new name daily during a backup job....
All found folder names are stored in: FolderName_1, FolderName_2, FolderName_3,...,etc.
Finally, the folder names are sorted in ascending order so that the last one is the latest backup folder.
Code: Select all
// Purpose: Search folders with names Backup yyyy-mm-dd hhmmss
// Folders only
Let>GFL_TYPE=1
Let>GFL_ATTRIBUTES=16
GetFileList>c:\Temp\Backup*.*,Folders
Separate>Folders,;,FolderName
ArraySort>FolderName
Let>LastFolder=FolderName_%FolderName_Count%
ChangeDirectory>LastFolder
MDL># of Folders Found: %FolderName_count%
-
- Pro Scripter
- Posts: 132
- Joined: Mon Dec 22, 2008 4:56 pm
- Location: St Augustine FL
Re: Changing to a dynamically named directory
Thanks for the code, Worked as expected until I hit the following directory structure
E:\Servers\ExchangeMailDBBkup\10282015_0500\WindowsImageBackup\servername\Backup 2015-10-28 213019
Not sure how to get by the third directory name, and yes it changes daily
Thanks
Gil
E:\Servers\ExchangeMailDBBkup\10282015_0500\WindowsImageBackup\servername\Backup 2015-10-28 213019
Not sure how to get by the third directory name, and yes it changes daily
Thanks
Gil
Thank you in advance for all your help
Gil
Gil
Re: Changing to a dynamically named directory
Please try the following code:gchichester wrote:Thanks for the code, Worked as expected until I hit the following directory structure
E:\Servers\ExchangeMailDBBkup\10282015_0500\WindowsImageBackup\servername\Backup 2015-10-28 213019
Not sure how to get by the third directory name, and yes it changes daily
Gil
Code: Select all
// Purpose: Search folders with names Backup yyyy-mm-dd hhmmss
// Your Target Folder Name: E:\Servers\ExchangeMailDBBkup\10282015_0500\WindowsImageBackup\servername\Backup 2015-10-28 213019
// My test Folder hierarchy: C:\Temp\ExchangeMailDBBkup\...
Day>Day
Month>Month
Year>Year
// Date for Folder Level 3 (FL3Date)
Let>FL3Date=%Month%%Day%%Year%
// Date for Folder Level 6 (FL6Date)
Let>FL6Date=%Year%-%Month%-%Day%
// Folders only
Let>k=1
Let>FL3=
Let>GFL_TYPE=1
Let>GFL_ATTRIBUTES=16
Repeat>k
Let>Srh=Srh%k%
If>k=1
Let>Srh=c:\Temp\ExchangeMailDBBkup\%FL3Date%_*.*
Else
Let>Srh=%FL3%\WindowsImageBackup\servername\Backup %FL6Date%*.*
Endif
GetFileList>Srh,Folders
Separate>Folders,;,FolderName
ArraySort>FolderName
Let>CurFolder=FL
ConCat>CurFolder,{if(%k%=1,"3","6")}
Let>%CurFolder%=FolderName_%FolderName_Count%
Add>k,1
Until>k>2
// Jump to Folder Level 6
ChangeDirectory>FL6