Hello all,
Could someone help me with a script to rename a text file?
Here is the task that I would like to accomplish:
When a user drop a text file to the script shortcut, it will use that file name and rename other file with that file name. For example:
There are 3 file on two different folder: File1.txt and File2.txt on one folder, and File3.txt on a different folder. When the user drop either File1 or File2 to the script shortcut, it would rename the File3 to File1 or File2_new.txt
Thanks.
Rename a file with a script
Moderator: DosItHelp
Re: Rename a file with a script
Code: Select all
@echo off
if /i "%~n1"=="file1" ren "c:\folderB\file3.txt" "%~n1_new.txt"
if /i "%~n1"=="file2" ren "c:\folderB\file3.txt" "%~n1_new.txt"
Re: Rename a file with a script
Thanks for the reply foxidrive. Sorry for not clear, the filename for file1 and file2 are randomly change to a different housename. We do not know what the housename the operator is going to drag to the script shortcut. Thanks.