Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 464 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to rename the files in the path with new different names in batch?

#1
I have one file destination.txt with path information about my CDs:

C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\SME99.ISO
C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\Biomasse.iso
C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\SAMPE36.ISO

Now I have to rename the ISOs with the numbers that are in the file PPN.txt one after another:

470692405
394006801
348117876
So it should be

SME99.ISO -> 470692405.ISO
Biomasse.iso -> 394006801.ISO
Sampe36.ISO -> 348117876.ISO
I have the following code for it:

< "PPN.txt" (for /F "usebackq delims=" %%a in ("destination.txt") do (
set/P out="" & rename "%%a" "!out!%%~xa"

I want to modify the code that way that it works for the file destination.txt:

Success on: "C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\SME99.ISO"
Error on: "C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\Biomasse.iso"
Success on: "C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\SAMPE36.ISO"

If "Success on" stays before the path in destination.txt the image should be renamed as always only with the number from PPN.txt.
But if "Error on" stays before the path in destination.txt the image should be renamed like this e_%number from PPN.txt% . So it should be additional prefix e_ there

Reply

#2
Try:

< PPN.txt (
for /F "delims=" %%a in (destination.txt) do (
set/P out="" & rename "%%a" "!out!%%~xa"&&echo Success on: "%%a"||(
echo Error on: "%%a" & rename "%%a" "e_!out!%%~xa"
)
)
)

`&&` will handle sucess of previous operations (`errorlevel` 0), `||` will handle failure.
Reply

#3
**Edit** Batch now takes the prefix into account, splitting the lines from `destination.txt` at the colon into `%%A` and `%%B`

@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
< "PPN.txt" (
for /F "usebackq tokens=1,* delims=:" %%A in ("destination.txt") do (
Set "out="
Set /P "out="
Set "out=!out: =!"
If /i "%%A" equ "Success on" (
ren %%B "!out!.ISO" && echo Renamed %%B to "!out!.ISO"
) Else If /i "%%A" equ "Error on" (
ren %%B "e_!out!.ISO" && echo Renamed %%B to "e_!out!.ISO"
) Else (Echo unknown prefix "%%~A")
)
)

Simulated ISO files returned this output:

Renamed "C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\SME99.ISO" to "470692405.ISO"
Renamed "C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\Biomasse.iso" to "e_394006801.ISO"
Renamed "C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\SAMPE36.ISO" to "348117876.ISO"

Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through