Need a hero (batch file with rename or move)

December 13, 2010 at 08:24:57
Specs: Windows 7
Batch file help need an example I don't know how to do this without using a rename if i could get some help i would greatly appreciate it the question is........
Many operating systems use the file command RENAME or MOVE to allow users to give a new name to an existing file. Suppose that in Windows Command Line, neither of these commands was available. Write a simple batch file that uses a combination of other existing commands that would perform the same function as RENAME/MOVE and explain your decision. Your batch file must be able to handle any filename provided to it by the user.

See More: Need a hero (batch file with rename or move)

Report •


#1
December 13, 2010 at 09:34:11
hint:

prompt for names
use COPY and DEL


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
December 13, 2010 at 12:10:03
Below is a snippet from a bat that gets input and converts it to Morse code.


Your input might be ren junk.txt good.txt
or ren drive\ folder\ file ext example ren c:\stuff\junk.txt stuff.dat
Then call or run test bat.

You could also start a test.bat and test.txt and add the following code at the end
***************************test.bat******************
cls
:start
set INPUT=
set /P INPUT=Type input: %=%
echo Your input was: %INPUT%
pause
echo %INPUT% >>temp.txt

:final
setlocal enabledelayedexpansion
set FINAL=
for /f %%a in (temp.txt) do (
set FINAL=!FINAL!%%a
)
echo %FINAL% >final.txt
endlocal
ren final.txt test.bat
test.bat
******************************temp.txt*******************
ren (type alt 255 after ren)
************************************************************

Without the final your input to the file will be
ren
c:\stuff\my.txt mystuff.dat

rather than ren C:\stuff\my.txt mystuff.dat


Just some thoughts....................

If you cannot use rename try a linux program


Report •

#3
December 13, 2010 at 12:56:16
You got me mystified.


=====================================
Life is too important to be taken seriously.

M2


Report •

Related Solutions

#4
December 13, 2010 at 15:32:35
My thought was.
Build a batch file in parts.
Then insert the users input.
................temp.bat..............
cls
@ echo off
echo for /f "delims==" %%F in ('dir /b /s *. >>temp.bat
echo set /P INPUT=Type input: %=%
echo Your input was: %INPUT%
pause
echo %INPUT% >>temp.bat

You would need to finalize it as it will come out as
for /f "delims==" %%F in ('dir /b /s *.
your input

instead of for /f "delims==" %%F in ('dir /b /s *.your input


Report •

#5
December 13, 2010 at 15:39:16
What does morse code have to do with rename or move?


=====================================
Life is too important to be taken seriously.

M2


Report •


Ask Question