I have a directory with filenames that I want to create a file from. the files are names below:
file1
file2
file3 ...
I want my final product to look like this:
catalog backuppiece 'Q:\dir\file1';
catalog backuppiece 'Q:\dir\file2';
catalog backuppiece 'Q:\dir\file3';
and so on...
any ideas? New to batch file.
thanks.
loop thru filenames in a directory
Moderator: DosItHelp
Re: loop thru filenames in a directory
dir /s /b *.* >filelist.txt
Re: loop thru filenames in a directory
You don't specify any type of file to filter ?
So here is a startup script that you can modify it as your needs:
So here is a startup script that you can modify it as your needs:
Code: Select all
@echo off
Mode 70,3 & Color 9E
Title Loop thru filenames in a directory
Set "MasterFolder=%userprofile%\desktop"
Set "OutPut=List_Files.txt"
::Rem Ext is set to all files by wilcard *
Set "Ext=*"
If exist "%OutPut%" Del "%OutPut%"
echo(
echo Please Wait a while we generate the output file ...
@For /f "delims=" %%a in ('Dir /s /b /A-D "%MasterFolder%\*.%Ext%"') Do (
cls
echo(
echo "%%a"
( echo catalog backuppiece '%%a';)>> "%OutPut%"
)
Start "" "%OutPut%"
-
- Posts: 3
- Joined: 24 Jul 2017 13:46
Re: loop thru filenames in a directory
Sorry this is what the files look like:
catalog backuppiece 'K:\oradata\recovery\rman\ciprod\CIPROD_CIPROD_2055_16_20170725_950301792.BAK';
catalog backuppiece 'K:\oradata\recovery\rman\ciprod\CIPROD_CIPROD_2055_17_20170725_950301792.BAK';
catalog backuppiece 'K:\oradata\recovery\rman\ciprod\CIPROD_CIPROD_2055_18_20170725_950301792.BAK';
catalog backuppiece 'K:\oradata\recovery\rman\ciprod\CIPROD_CIPROD_2055_19_20170725_950301792.BAK';
catalog backuppiece 'K:\oradata\recovery\rman\ciprod\CIPROD_CIPROD_2055_1_20170725_950301792.BAK';
catalog backuppiece 'K:\oradata\recovery\rman\ciprod\CIPROD_CIPROD_2055_20_20170725_950301792.BAK';
Your bat worked. I had to modify the location from Desktop to K:\...
worked great thank you.
new to bat files.
want to learn though.
catalog backuppiece 'K:\oradata\recovery\rman\ciprod\CIPROD_CIPROD_2055_16_20170725_950301792.BAK';
catalog backuppiece 'K:\oradata\recovery\rman\ciprod\CIPROD_CIPROD_2055_17_20170725_950301792.BAK';
catalog backuppiece 'K:\oradata\recovery\rman\ciprod\CIPROD_CIPROD_2055_18_20170725_950301792.BAK';
catalog backuppiece 'K:\oradata\recovery\rman\ciprod\CIPROD_CIPROD_2055_19_20170725_950301792.BAK';
catalog backuppiece 'K:\oradata\recovery\rman\ciprod\CIPROD_CIPROD_2055_1_20170725_950301792.BAK';
catalog backuppiece 'K:\oradata\recovery\rman\ciprod\CIPROD_CIPROD_2055_20_20170725_950301792.BAK';
Your bat worked. I had to modify the location from Desktop to K:\...
worked great thank you.
new to bat files.
want to learn though.
-
- Posts: 3
- Joined: 24 Jul 2017 13:46
Re: loop thru filenames in a directory
this change worked.
::Rem @For /f "delims=" %%a in ('Dir /s /b /A-D "%MasterFolder%\*.%Ext%"') Do (
@For /f "delims=" %%a in ('Dir /s /b /A-D "%MasterFolder%\CIPROD*.%Ext%"') Do (
I only want to pick up files like this:
catalog backuppiece 'K:\oradata\recovery\rman\ciprod\CIPROD_CIPROD_2055_20_20170725_950301792.BAK';
thanks.
::Rem @For /f "delims=" %%a in ('Dir /s /b /A-D "%MasterFolder%\*.%Ext%"') Do (
@For /f "delims=" %%a in ('Dir /s /b /A-D "%MasterFolder%\CIPROD*.%Ext%"') Do (
I only want to pick up files like this:
catalog backuppiece 'K:\oradata\recovery\rman\ciprod\CIPROD_CIPROD_2055_20_20170725_950301792.BAK';
thanks.