What I want to do:
I'm basically trying to have inside of my command something along the lines of: "if haha.txt exists, rename to lol.txt". However, there are going to be many haha.txt files in many different directories, and in order for it to work, I need to be able to run this command, and have it only rename the haha.txt file in my current directory. However, in all my attempts, it always seems to want me to specify exactly where the file is located, which won't work. (Perhaps it's because the command is in the path, not this folder?)
So the question is:
Is there any way to use the
REN command in a batch file without specifying the directory, and instead have it rename in your current directory?
Edit: As requested, here's my script (with all the stuff not important to us taken out of it)
Also, some other info:
- Name: SSHCrack.cmd
- Opened by: Opening command prompt, going to a folder with uncrackedSSH.txt, and typing SSHCrack 22
- Purpose: Renaming uncrackedSSH.txt to crackedSSH.txt
- Located in: Path
@echo off title SSHCrack set x=%1 if not defined x goto unknown if %x%==22 ( goto correct ) else ( goto wrong ) :correct echo SSHCrack running... if exist uncrackedSSH.txt ( ren uncrackedSSH.txt crackedSSH.txt echo -- SSHCrack Complete -- goto end ) if exist crackedSSH.txt ( echo SecureShell port already open goto end ) else ( echo SecureShell port not found goto end ) :unknown echo Please specify a port number goto end :wrong echo Wrong port number :end title cmd.exe
I've tried using "ren .\uncrackedSSH.txt crackedSSH.txt", using "cd %cd%" to link to the current directory, tried directly linking with a specific folder with "cd /d C:\SpecificFolder", and tried putting the .bat file in the same folder as uncrackedSSH.txt and running it from there, but I always end up receiving:
SSHCrack Running... The system cannot find the file specified. -- SSHCrack Complete --
Whenever I go to the folder, the name of uncrackedSSH.txt hasn't changed.