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.
Move the first file in a folder
Name: dolly Date: May 13, 2009 at 15:38:12 Pacific OS: Windows XP Subcategory: Batch
Comment:
Hi
I just need to separate(move) one file from a folder containing n (n>=1) number of files to a different folder eg: Folder A has I1.txt I2.txt I3.txt move I1.txt to folderB . Please note : file names are dynamic so I cannot look for file stating with I1* . Regardless of file name and extension , move one file from the folder. Thanks Dolly
Name: Valerie (by Garibaldi) Date: May 13, 2009 at 19:13:05 Pacific
Reply:
Here's one way, change copy to move when you're finished testing:
@echo off
cls
for /f "delims=*" %%1 in ('dir /b a\') do (
copy "%%1" b\ > nul & exit /b
)
0
Response Number 2
Name: Mechanix2Go Date: May 14, 2009 at 10:46:50 Pacific
Reply:
Depends on how you define first.
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 3
Name: dolly Date: May 14, 2009 at 12:21:44 Pacific
Reply:
Hi
Thanks for your reply..But somehow I was not able to use the code because it was throwing me error saying system could not find the specified file.. came up with the following code which is working..Thanks all .. here is my code I dont know how good it is but serves my purpose .. @ECHO ON REM This is to copy all to an archive folder and move first file regardless of name & extn to a different folder and move rest of files to another folder. set dr_cb=C:\prc set drcb_O8322=C:\out\archive set drcb_O832T1=C:\Temp1 set drcb_O832T2=C:\Temp2 Set fnam_cb=I* set l_cbcon=('"dir /B /A:-D %dr_cb%\I*"') FOR /F %%G IN %l_cbcon% DO ( if exist %dr_cb%\%%G ( copy %dr_cb%\%%G %drcb_O8322%\%%G ) )
FOR /F %%G IN %l_cbcon% DO ( move %dr_cb%\%%G %drcb_O832T1%\%%G goto :end1 ) :end1 move %dr_cb%\I* %drcb_O832T2%\ del /Q %dr_cb%
Summary: Hi, I need to zip all the .csv files in a folder file by file..i donot want to zip the entire folder..just the csv files in a folder... suppose i have 10 .csv files in a folder..then my .bat script sh...
Summary: I would like to create a .bat file that finds the first file in a folder on an FTP server. FTP Server RandomFolder <- find the first file in this folder index.html ^Stuff on server I know I have to...
Summary: HI, I need to write a batch script which will unzip all the .Zip files from a folder XYZ. Inside the folder XYZ there are multiple .Zip files I need to unzip them and place them in my target directory...