Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Batch file only works in certain directory

29 Nov 2013   #1
pen island

Windows 7 Ultimate x64
 
 
Batch file only works in certain directory

I made a batch file that says this:

Code:
@echo off
cd C:\Users\John\Desktop
rename ring.gif ring.jpeg
The actual batch file is saved on my I:\ drive, not my C:\ drive. My I:\ drive is an internal HDD that is able to talk with my C:\ drive. When I execute the .bat file, it does nothing besides quickly opening the command prompt and then closing it. When I take the .bat file and put it on my desktop and run it, it works as it should (ring.gif gets renamed to ring.jpeg). Why doesn't it work when it is on my I:\ drive?


My System SpecsSystem Spec
.
29 Nov 2013   #2
logicearth

Windows 10 Pro (x64)
 
 

You need to add the "/D" switch to cd that might help. "cd /D C:\Path..."
My System SpecsSystem Spec
29 Nov 2013   #3
pen island

Windows 7 Ultimate x64
 
 

It worked like a charm. Thank you very much!
My System SpecsSystem Spec
.

Reply

 Batch file only works in certain directory




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Batch File: works under cmd-Windows , NOT under MS-DOS
I made these codes to backup files : set p=C:\Users\ for /f %%a in ('dir C:\Users\ /b') do ( if not "%%a"=="Public", ( set fileDest=C:\Backup-%%a_%date:~7,2%.%date:~4,2%.%date:~10,4%
Virtualization
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
question - batch file only works with "unofficial" directory name
Hello... I'm using a command line batch file to backup files from my W7 Pro x64 machine to an external USB HD. Basically, "xcopy c:\......\my documents\*.*" "external HD". I couldn't get this to work until I truncated the source directory to "documents" instead of "my documents" . While the batch...
General Discussion
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
Batch file or Exe to copy & rename directory and update files
I require a batch file or free utility that i can redistribute from my web site to other users, (gamers) that will copy the contents of a directory inside their game to a new location and re-name the directory at the same time. Something like this; Copy "Genesis\Vehicles\truck\diesel\4tonbaker"...
General Discussion
I need to covert a batch of wks(Works) files to xls(Excell)
I am working on a pc that has important wks files created in a very old Works program, I believe ver 4. There are about 70 files. I am trying to transfer these file to a new computer with MS Office installed. I have read on the internet that I can open the files one at the time with Excell and save...
Microsoft Office


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 23:14.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App