Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-11-2012, 10:00 AM
raghuk raghuk is online now
Registered User
 
Join Date: 02-10-2012
Posts: 11
Rename file to its folder's name.

I have about 20 directories which get updated every day at a certain location in the system.

Eg.,

ABC folder contains ABC_2012_04_11_045308_1288340.txt

XYZ folder contains XYZ_2012_04_11_045308_1288340.txt

I need to loop through each folder,

- find the file that matches the folder name
- Rename the file to its folder name

Eg., ABC_2012_04_11_045308_1288340.txt Should become ABC.txt

Here's what I'm doing.

<step action='Rename Files'>
<Dir>%PROCFILES_ROOT_DIR%%PROCFILES_FILE_DIR%</Dir>
<Ext>*.bak</Ext>
<Find> [FormatDirectoryName("%PROCFILES_FILE_DIR%")]</Find>
<FirstOnly type='11'>0</FirstOnly>
<HideOn type='11'>-1</HideOn>
<LogRenamed type='11'>-1</LogRenamed>
<LogUnchanged type='11'>-1</LogUnchanged>
<Replace> [FormatDirectoryName("%PROCFILES_FILE_DIR%")]</Replace>
<SysOn type='11'>-1</SysOn>
<indent type='3'>2</indent>
<name>Rename Files</name>
</step>

I see that the above step finds the files, but does not rename them. What am I missing?

Renaming files/folders in 'D:\Backups\ABC\'...
ABC_2012_04_11_045308_1288340.txt not renamed
1 file(s)/folder(s) processed, 0 file(s)/folder(s) renamed
4/11/2012 10:46:30 AM: Building project step 16 - Process Files ALL...
Reply With Quote
  #2  
Old 04-11-2012, 10:41 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
See the attached sample.
Attached Files
File Type: bld RenameFiles.bld (1.8 KB, 1581 views)
Reply With Quote
  #3  
Old 04-11-2012, 11:17 AM
raghuk raghuk is online now
Registered User
 
Join Date: 02-10-2012
Posts: 11
That worked.. I had to check "Process once for each folder containing matching files".

Thank you!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 12:12 PM.


Copyright © 1999-2023 Kinook Software, Inc.