Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to rename some files, only if: "copy *.txt ..\50-*.txt" worked. Basically, I have a GROUP of directories (I have about 15 Groups, each with about 150 directories, each directory has a descriptor file and a folder of the same name (without the .txt).
ie: C:\GroupA\50\canada.txt describes what C:\GroupA\50\Canada\*.* is. (under 50\ there might be canda.txt, usa.txt, mexico.txt, etc...
Since over all I have about 15 Groups X 150 Dirs X ~10 SubDirs (22500 files alltogether) it needs to be repetitive and recursive.
the file names are 90% different but repetition does occure (ie: I may have C:\GroupA\50\Canada.txt and C:\GroupA\11\Canada.txt and C:\GroupA\97\Canada.txt).
I would like to take (respective to listed above) and create
C:\GroupA\50-Canada.txt, C:\GroupA\11-Canada.txt, C:\GropuA\97-Canada.txt)
I have "first.bat" which is called from the Group (GroupA) and it says (manually made, would be nice to make automatically):call second.bat 01
call second.bat 02
and I want (dynamic) second.bat to create a (static) third.bat which then it will execute:ie:
second.bat says
dir %1\*.txt > %1.bat blah.txt" how can I insert my own text into blah.txt so that I can create a functioning batch file. (IE: similarly to C/C++ when it's:
cout << "this is my variable: " << var << "!" << endl;
If there is a % variable that will keep full name and simply build onto the beginning - I would gladly work with that.
Any help is greatly appreciated,
Thanks,
-- Ian

Hmmm... Your doubt is not very clear to me.
Please confirm this: You have the following generic directory path:
C:\GROUP\DIR\SUBDIR
ex:
C:\GroupA\50\Canada
C:\GroupB\25\BrazilYou want to get all files with .txt extention under each DIR (not the ones under the SUBDIRs) and copy to the GROUP which contains that DIR, with the name of the DIR (from where it came) followed by "-" and the original filename.
Example - let's say you have:
C:\GroupA\50\Canada.txt
that file would be copied to
C:\GroupA\50-Canada.txtIs that it ??
If not, please explain better.Once I have understood you I can help.
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

Your OS (Operational System) would also be a valuable information.
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

Secret_Doom:
Yes, Your above interpretation is correct.
the OS in question currently is WinXP/2K
Further tinkering led me to two different methods of solving this problemL
A) a copy statement that will allow me to do as above mentioned:C:\GroupA\50\Canada.txt
would be copied to
C:\GroupA\50-Canada.txt
B) a statement that will allow me to parse file, line by line, created by "dir *.txt /b" and the value that will be read into a batch file as a % value.
Thanks for the help,
-- Ian

The following batch script should work for Win2K/XP:
@echo off
for /d %%a in (*) do (
cd %%a
for /d %%b in (*) do (
cd %%b
for %%c in (*.txt) do (
:: Remove 'echo.{demo}' to activate script
echo.{demo}copy %%c ..\%%b-%%c
)
cd..
)
cd..
)It should be runned from the root directory (or the directory which contains the GROUPS directories)
This script is de-activated. Run and check the output to the screen: if when runned it would take the desired effect, then activate the script (read commented line).
I only tested it in Win95Cmd.exe, which is some sort of a Win2000's CMD.exe emulator for windows 95.
Keep in mind that such script will *NOT* work on any DOS-based system (such as Dos6.22 and Windows9x).
-- Secret_Doom - Leonardo Pignataro --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
GHOST -> DOS -> USB
|
dosstart.bat
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |