[Batch/CMD] Написание батника по переименованию файлов

  • Автор темы Автор темы Mart1z
  • Дата начала Дата начала

Переводчик Google

Статус
В этой теме нельзя размещать новые ответы.
Hello. Please write a .bat file for windows 10 that renames the files in the folder where the batch file is run. You need to remove the "-" sign at the beginning of the file name and "0-" in the middle. For example: a file of the form -ABC-11042024-0-1530_name.ts to ABC-11042024-1530_name.ts
Also, this .bat file should not affect other files that don't have a "-" at the beginning
 
Hello. Please write a .bat file for windows 10 that renames the files in the folder where the batch file is run. You need to remove the "-" sign at the beginning of the file name and "0-" in the middle. For example: a file of the form -ABC-11042024-0-1530_name.ts to ABC-11042024-1530_name.ts
Also, this .bat file should not affect other files that don't have a "-" at the beginning
To rename files in the folder where the batch file is run by removing the "-" at the beginning of the file name and "0-" in the middle, while ensuring that files without "-" at the beginning remain unaffected, you can use the following batch script:

CMD/BATCH:
@echo off
setlocal enabledelayedexpansion

rem Renaming files in the current directory
for %%f in (*-*.*) do (
    set "filename=%%~nf"
    if "!filename:~0,1!"=="-" (
        set "new_filename=!filename:~1!"
        set "new_filename=!new_filename:0-=!"
        ren "%%f" "!new_filename!%%~xf"
    )
)

echo All files renamed successfully!

This script will iterate through all files in the current directory that have "-" in their names. It will check if the file name starts with "-", and if so, it will remove the "-" at the beginning and "0-" in the middle. Other files that do not start with "-" will remain unchanged.

Save this script in a .bat file and run it in the folder where you want to rename the files. Let me know if you need any further assistance!
 
Hello. Please write a .bat file for windows 10 that renames the files in the folder where the batch file is run. You need to remove the "-" sign at the beginning of the file name and "0-" in the middle. For example: a file of the form -ABC-11042024-0-1530_name.ts to ABC-11042024-1530_name.ts
Also, this .bat file should not affect other files that don't have a "-" at the beginning

After that, copy the resulting files to "\\User2\grid".
 
Hello. Please write a .bat file for windows 10 that renames the files in the folder where the batch file is run. You need to remove the "-" sign at the beginning of the file name and "0-" in the middle. For example: a file of the form -ABC-11042024-0-1530_name.ts to ABC-11042024-1530_name.ts
Also, this .bat file should not affect other files that don't have a "-" at the beginning

After that, copy the resulting files to "\\User2\grid".
Here is a batch script that renames files in the folder where the batch file is run by removing the "-" at the beginning of the file name and "0-" in the middle, and then copies the resulting files to "\\User2\grid":

CMD/BATCH:
@echo off
setlocal enabledelayedexpansion

rem Renaming files in the current directory
for %%f in (*-*.*) do (
    set "filename=%%~nf"
    if "!filename:~0,1!"=="-" (
        set "new_filename=!filename:~1!"
        set "new_filename=!new_filename:0-=!"
        ren "%%f" "!new_filename!%%~xf"
        copy "%%f" "\\User2\grid"
    )
)

echo All files renamed and copied successfully!

This script will first rename files in the current directory by removing "-" at the beginning and "0-" in the middle, and then copy the resulting files to the "\\User2\grid" directory. Files that do not start with "-" will remain unchanged.

Save this script in a .bat file and run it in the folder where you want to rename and copy the files. Let me know if you need any further assistance!
 
Hello. Please write a .bat file for windows 10 that renames the files in the folder where the batch file is run. You need to remove the "-" sign at the beginning of the file name and "0-" in the middle. For example: a file of the form -ABC-11042024-0-1530_name.ts to ABC-11042024-1530_name.ts
After that, copy the renamed files to "D:\files"
Also, this .bat file should not affect other files that don't have a "-" at the beginning
 
Hello. Please write a .bat file for windows 10 that renames the files in the folder where the batch file is run. You need to remove the "-" sign at the beginning of the file name and "0-" in the middle. For example: a file of the form -ABC-11042024-0-1530_name.ts to ABC-11042024-1530_name.ts
After that, copy the renamed files to "D:\files"
Also, this .bat file should not affect other files that don't have a "-" at the beginning
Here is a batch script that renames files in the folder where the batch file is run by removing the "-" at the beginning of the file name and "0-" in the middle, and then copies the renamed files to "D:\files":

CMD/BATCH:
@echo off
setlocal enabledelayedexpansion

rem Renaming files in the current directory and copying to D:\files
for %%f in (*-*.*) do (
    set "filename=%%~nf"
    if "!filename:~0,1!"=="-" (
        set "new_filename=!filename:~1!"
        set "new_filename=!new_filename:0-=!"
        ren "%%f" "!new_filename!%%~xf"
        copy "%%~dpnxf" "D:\files"
    )
)

echo All files renamed and copied successfully to D:\files!

This script will rename files in the current directory by removing the "-" at the beginning of the file name and "0-" in the middle. It will then copy the renamed files to the "D:\files" directory. Files that do not start with "-" will remain unchanged.

Save this script in a .bat file and run it in the folder where you want to rename and copy the files. Let me know if you need any further assistance!
 
Hello. Please write a .bat file for windows 10 that renames and copies files in the folder where the batch file is running. You need to remove the "-" sign at the beginning of the file name and "0-" in the middle. For example: a file of the form -ABC-11042024-0-1530_name.ts to ABC-11042024-1530_name.ts
Copy the affected files to the "D:\files" folder.
Also, this .bat file should not affect other files that do not have a "-" at the beginning.
 
Please write a .bat file for windows 10 that renames and copies files in the folder where the batch file is running. You need to remove the "-" sign at the beginning of the file name and "0-" in the middle. For example: a file of the form -ABC-11042024-0-1530_name.ts to ABC-11042024-1530_name.ts
Then copy the affected files to the "D:\files" folder.
Also, this .bat file should not affect other files that do not have a "-" at the beginning.
 
Статус
В этой теме нельзя размещать новые ответы.
Назад
Сверху Снизу