Continue name and numbering [closed] - batch-file

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am trying to add photos to existing photo folder. If my last photo in the folder is photo 56.jpg and I want to add 10 more new photos and want them to continue name and numbering like photo 57.jpg ; photo 58.jpg so on....
Can some one help with a batch file for this.

#echo off &SETLOCAL ENABLEDELAYEDEXPANSION
SET "photofolder=photos"
SET "newfolder=newphotos"
FOR %%a IN ("%photofolder%\Photo *.jpg") DO (
FOR /f "tokens=2" %%b IN ("%%~na") DO IF %%b gtr !hi! SET /a hi=%%b
)
FOR %%a IN ("%newfolder%\*.jpg") DO (
SET /a hi+=1
COPY "%%~fa" "%photofolder%\Photo !hi!%%~xa"
)

Related

Loop in .bat file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 20 days ago.
Improve this question
I must rename more hundred files, they are numbered
on the left, from 01 to 100, on the right side from G3002185 to G3002285
i use this script
rename 01.pdf G3002185.pdf
rename 02.pdf G3002186.pdf
rename 03.pdf G3002187.pdf
rename 04.pdf G3002188.pdf
rename 05.pdf G3002189.pdf
rename 06.pdf G3002130.pdf
(...)
but I would like to shorten it, is there an option to loop it somehow?
#ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /L %%c IN (1001,1,1100) DO (
SET "oldname=%%c"
SET /a newname=3002185 - 1001 + %%c
IF %%c==1100 (SET "oldname=!oldname:~-3!") ELSE (SET "oldname=!oldname:~-2!")
ECHO REN "!oldname!.pdf" "G!newname!.pdf"
)
GOTO :EOF
Always verify against a test directory before applying to real data.
The required REN commands are merely ECHOed for testing purposes. After you've verified that the commands are correct, change ECHO REN to REN to actually rename the files.
Your example appears to be faulty. "06" should be renamed to "G3002190".
And your count is incorrect. The last new-filename should be "G3002284.pdf"

Rename multiple files according to the given situation in cmd [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have several files like the following:
fluxes_30.880_77.040
fluxes_30.880_77.050
fluxes_30.900_77.020
Here the numerical values are latitude and longitude.
I need to change the name of all the files in the form:
fluxes_30.88_77.04
fluxes_30.88_77.05
fluxes_30.90_77.02
Simply, I need the latitude and longitude values in two digits, How to rename all these in command prompt?
#echo off
setlocal EnableDelayedExpansion
for /F "tokens=2,3 delims=_" %%a in ('dir /B /A-D fluxes_*') do (
set "lat=%%a"
set "long=%%b"
ren "fluxes_%%a_%%b" "fluxes_!lat:~0,-1!_!long:~0,-1!"
)
I don't think this simple code needs further explanations...

CMD i need to move certain files in certain directory [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
well, this is kind a simple.. i have lots file with some certain srting and i wants to move to certain folders using .bat script
here is examples
files
ABCD_Afile_1111-11111111_00001.txt
ABCD_Bfile_2222-22222222_00001.txt
ABCD_Cfile_3333-33333333_00001.txt
ABCD_Dfile_4444-44444444_00001.txt
and i wants to move this files like below
folder Afolder_1111-11111111
ABCD_Afile_1111-11111111_00001.txt
Folder Bfolder_2222-22222222
ABCD_Bfile_2222-22222222_00001.txt
folder CFolder_3333-33333333
ABCD_Cfile_3333-33333333_00001.txt
folder DFolder_4444-44444444
ABCD_Dfile_4444-44444444_00001.txt
the script should find the folder by file string 1111-1111111 and move that file to its desired folder.
i have made a batch script by my self.. but its not Exactly as i want...
eg
move D:/x/fikename.txt foldernamehere
i have to put folder name mannualy that's the problem for me..
Thanks #stephan
for %%f in (X\:x\*.txt) do ( for /f "tokens=3 delims=_" %%a in ("%%~nf") do ( for /d %%x in (X:\x\*%%a) do ( ECHO move "%%~ff" "%%x\" ) ) )
This codes works
assuming all of your files follow this syntax XXXX_Yfile_0000-00000000_00000.txt:
#echo off
for %%f in (X:x\*.txt) do (
for /f "tokens=3 delims=_" %%a in ("%%~nf") do (
for /d %%x in (X:\x\*%%a) do (
ECHO move "%%~ff" "%%x\"
)
)
)
remove the ECHO if the output looks right.

Batch: Save multiple files with same extension but in another directory [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I need to write a script that saves all the files processed by the batch at the same time, with the same extension (.P3D) but in another directory, I tried this but it did not work, please help me
bat1.bat:
set var=1 0
start cmd goto /k bat2
bat2.bat
set src_folder=C:\Users\kaue9\Desktop\ResLodRemover\OriginalPlants2Trees
set dst_folder=C:\Users\kaue9\Desktop\ResLodRemover\teste
for /R %src_folder% %%f in (*.p3d) do ResLodRemover.exe %%f %dst_folder%\*.p3d %var%
the problem is in %dst_folder%, ty guys
Best guess:
bat1.cmd
#SET "var=1 0"
#CALL "bat2.cmd" "%var%"
bat2.cmd
#SET "src_folder=%UserProfile%\Desktop\ResLodRemover\OriginalPlants2Trees"
#SET "dst_folder=%UserProfile%\Desktop\ResLodRemover\teste"
#FOR /R "%src_folder%" %%A IN (*.p3d
) DO #ResLodRemover.exe "%%~A" "%dst_folder%\%%~nxA" %~1

how to write a basic batch process to copy files from one location to another location on windows 7 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How do I write a basic batch process to copy files from one location to another location and give a limit or rule where I can enter the number of files that can be copied and from which file to which file?
Example: If I have 300 files I want to just copy from 50 to 250 files.
#ECHO OFF
SETLOCAL
SET "destdir=c:\destdir"
SET "source=%cd%\*.bat"
for /f "tokens=1*delims=:" %%i in (
'xcopy /L /y "%source%" "%destdir%\" ^|findstr /n ":" '
) DO (
IF %%i leq 12 ECHO XCOPY "%%j" "%destdir%\"
)
should do the job, echoing the first 12 copies to be performed, copying the batch files from the current directory to the destination.
The process relies on : in the source filename, so %cd% is used in preference to .

Resources