Computing.Net > Forums > Programming > .bat file to count and rename

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

.bat file to count and rename

Reply to Message Icon

Name: hlw9
Date: June 25, 2007 at 11:36:59 Pacific
OS: XP
CPU/Ram: Intel core, 2GB RAM
Product: Dell
Comment:

Hello,
I am looking for code to help create a .bat file for Windows that does the following:

count = Number of files in a folder
if count == 0, exit
else
FOR all files in the folder
set ORIGINALFILENAME = filename of file1
rename file1 to (hardcoded) ABC.dat
run sqlloader on ABC.dat
rename ABC.dat to ORIGINALFILENAME.dat
move ORIGINALFILENAME.dat to another
folder
next file

end

Any assistance if very much appreciated!



Sponsored Link
Ads by Google

Response Number 1
Name: hlw9
Date: June 25, 2007 at 11:53:45 Pacific
Reply:

Also, I have the command to run sqlloader. But, not the code around it.


0

Response Number 2
Name: Mechanix2Go
Date: June 26, 2007 at 01:57:23 Pacific
Reply:

@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir/b/a-d *.dat') do (
ren %%a ABC.dat
echo do the sql on ABC.dat
ren ABC.dat %%a
echo move %%s d:\some\place
)



=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 3
Name: Mechanix2Go
Date: June 26, 2007 at 04:38:11 Pacific
Reply:

CORRECTION

::==
@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir/b/a-d *.dat') do (
ren %%a ABC.dat
echo do the sql on ABC.dat
ren ABC.dat %%a
echo move %%a d:\some\place
)
::==


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 4
Name: hlw9
Date: June 26, 2007 at 08:43:45 Pacific
Reply:

Thank you very, very much! That is exactly what was needed. Working fine.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Can't uninstall Java JDK ... VB Chat program



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: .bat file to count and rename

BAT File to Increment File Name +1 www.computing.net/answers/programming/bat-file-to-increment-file-name-1/17272.html

copy a file 3300 times and rename it www.computing.net/answers/programming/copy-a-file-3300-times-and-rename-it-/18821.html

BAT file to open multiple windows www.computing.net/answers/programming/bat-file-to-open-multiple-windows/7513.html