I am trying to rename files in a batch script as follows:
rename %FOLDER%\* 1-*
but when you run the script, it overwrites the first two characters of the original names with the prefix "1-" instead of adding it to the beginning of the file names. How can I get around this?
Rename will simply rename the file, you will need to call the file name as a variable after the prefix. The following shows how it works.
cd %folder% for %%a in (*) do rename "%%a" "1-%%a"
try this as a starting point
@echo off for %%a in (%folder%\*) do ( echo ren "%%~fa" "1-%%~nxa" )
Source: https://habr.com/ru/post/1387451/More articles:Check if the IP address is on the network - functionWhat does this [Serializable] attribute that ISERializable does not support? - c #The exact way to measure overhead in kernel space - performanceTemplate class specialization for several types satisfying the condition - c ++the most common configuration flags for installing R from a source on 64-bit Ubuntu - rMiniProfiler to profile my ajax requests - javascriptWhat objects are terminated in Go by default and what are some of these errors? - garbage-collectionWhy does DateTimeConverter.ConvertFrom work with empty strings? - c #iOS - how to compare twice? - iosCan a custom editorTemplate call EditorTemplate by default for the same model inside it - asp.net-mvcAll Articles