Category filter
Script to rename files on Windows devices
Management of files becomes easier if they are named sensibly. Hexnode lets admins to rename files on multiple devices simultaneously using scripts.
Batch Script
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
@echo off REM === Set the folder path and file names === set "TargetPath=C:\Path\To\Your\Folder" set "OldName=original_filename.ext" set "NewName=new_filename.ext" REM === Navigate to the target folder === cd /d "%TargetPath%" REM === Check if the file exists and rename === IF EXIST "%OldName%" ( ren "%OldName%" "%NewName%" echo File renamed successfully from "%OldName%" to "%NewName%" in "%TargetPath%". ) ELSE ( echo File "%OldName%" not found in "%TargetPath%". Rename failed. ) |
set “TargetPath=C:\Path\To\Your\Folder”
set “OldName=original_filename.ext”
set “NewName=new_filename.ext”
In the above command, replace the terms “C:\Path\To\Your\Folder”, “original_filename.ext”, “new_filename.ext” with actual path and names.
PowerShell Script
|
1 |
rename-item "current_filename_with_path.ext" "new_filename_with_path.ext" |
E.g., To rename the file test.txt in the Desktop of the user Deborah to testing.txt,
rename-item “C:\Users\Deborah\Desktop\test.txt” “C:\Users\Deborah\Desktop\testing.txt”
