Over 1 million tech questions and answers.

IF Exists in Batch File

Q: IF Exists in Batch File


I have a exe file in the Folder call FChart 4.0.1. I would like to write the batch script to check if FChart.exe exists in the FChart 4.0.1 folder then copy it to specified folder. NOTE: the issue is that I would like to have it generic therefore I want to avoid 4.0.1 and only look for FChart folder and then file inside. I've written script but it doesnt work and its not generating any error as well

IF EXIST "VMFChart *\VMFChart.exe" XCOPY "VMFChart *\*" "%vmpath%" /E /F /G /H

Thanks in Advance

Preferred Solution: IF Exists in Batch File

I recommend downloading and running Reimage. It's a computer repair tool that has been proven to identify and fix many Windows problems with a high level of success.

I've used it in the past to identify and fix everything from blue screens (BSOD's), ActiveX errors, corrupt files and processes, dll/exe/sys errors, recover lost memory, Windows update problems, defragging, malware removal etc.

You can download it direct from this link http://downloadreimage.com/download.php. (This link will automatically start a download of Reimage that you can save to your computer.)

A: IF Exists in Batch File

Is the file name FChart.exe or VMFChart.exe? The text says FChart.exe, the command says VMFChart.exe. Same with the folder name.

Easiest way is to try to switch to the FChart* folder. If that succeeds, you then check for the file and copy it.
If FChart 4.0.1 is a folder under the Program Files folder, this should work:

@Echo Off
PushD %ProgramFiles%
PushD FChart* 2>Nul
If Errorlevel 1 Goto _NotFound
If Exist FChart.exe XCOPY "FChart.exe" "%vmpath%" /E /F /G /H
Goto _Copied
Echo FChartXXX folder not found in %CD%
Goto :EOF
Echo FChart.exe copied to %vmpath%
Note that if you have different versions (FChart 4.0.1 and FChart 4.0.2), it will switch to the the first one as listed in a Dir command that is sorted by name. Names with numbers aren't always listed in the same order as in Windows Explorer.



Read other 2 answers

I have a DOS batch file that moves files from one directory and sorts them into separate folders alphabetically. The problem is existing files get replaced. I know I can add the -y switch to be prompted but there's too many prompts. Does anyone know how I can skip if file exists automatically? I don't see that option anywhere in dos move command. Was wondering if I can use the "IF" variable somehow. Like IF exists skip or no replace etc. Can't find answer anywhere on web. TIA any help. Here is an excerpt from my batch file:

move a*.* D:\!TLF\a
move b*.* D:\!TLF\b
move c*.* D:\!TLF\c
move d*.* D:\!TLF\d
move e*.* D:\!TLF\e
move f*.* D:\!TLF\f
move g*.* D:\!TLF\g

Read other answers

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...

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 folder\video.mp4 -f mp3 -ab 160000 -vn "\different folder\music.mp3"

what I would like to do is add to this so that I don't have to write out this code for every file I have... :/

I have the mp4 files in one folder and than the mp3 files are saving to another folder.

So here's an example of what the code will do if it isn't clear yet.

Folder 1:


what it should do is grab video1.mp4 and convert it.

ffmpeg -i folder\video1.mp4 -f mp3 -ab 160000 -vn "\different folder\music1.mp3"

and than move onto the next one

ffmpeg -i folder\video2.mp4 -f mp3 -ab 160000 -vn "\different folder\music2.mp3"

and than the next one

ffmpeg -i folder\video3.mp4 -f mp3 -ab 160000 -vn "\different folder\music3.mp3"

It's going to have to grab the name from the mp4 file and insert it for the mp3 file.

I can get around pretty good in cmd if it's basic commands but when it comes to something like this I'm a little confused...

Thanks for the help in advance!
I'll see what i can do about searching some more on what I would have to do and if I find the solution I'll post it here if it isn't already answered.

A:Batch File that grabs file names from folder to insert into batch file

A DOS "for /f" loop should do the trick, although changing the filename extension for the output to do everything in one line escapes me at the moment.

Perhaps you could do a dir .\folder\*.mp4/s/b > mp4s.txt, then make a copy of that and edit each line to rename the file to the destination name, and save it as mp3s.txt. Then you just feed both the source (mp4s.txt) and destination (mp3s.txt) filesnames into the for /f loop which handles the ffmpeg conversion.

Quite a crude solution and you'd have to handpatch the destination filenames, but i can't think of how to get a source mp4 filename and then just change the extension.

Read other 3 answers

I have a question  that how to copy file from remote desktop user drive to my local machine using  xcopy or any other protocol.

This is my server path "\\Trail01" and here is the file location "c:\Users\ashique.sheikh\Desktop\Day2.R"
How can i give this is in my batch file. I have used this
net use "\\Trail01" "[email protected]" "/USER:ashique.sheikh"
XCOPY /Y \\Trail01\c:\users\ashique.sheikh\Desktop\Day2.R  "D:\VMI"
But its not working. It is give path error.
How can i download this or is there any other way to do it?

Read other answers

If someone can Please help, I just need the Data in the XML tag extracted to Batch File Variable....the rest i figured out and works great for the backup...just need the extracted tags...
thank you

i have a parent directory that contains a sub directory and a XML file that i need a batch to read 2 specific tags then create a Set command in the batch with those 2 lines to create a backup folder with the tags as the names and such. looks like this:

Parent Directory = XML
XML Folder contains > WJFKB02229001.D Folder & Config.xml File

I need to read the contents of the xml "Config.xml" extract the PhaseID Tag data "WJFKB02229001"
Also need to extract the BoxID "D", I don't need anything else on these seperate lines.

keep trying the following For /F command but no luck
[COLOR=red]for /f "tokens=1 delims=[" %%G in ("PHASEID" %path%\%myfile%) DO ([/COLOR]
[COLOR=red]set PhaseID=%%G[/COLOR]
[COLOR=red]echo Phase: %PhaseID%[/COLOR]

and i've searched so many sites and forums with no real help on this one....the data is contained in the xml, weird enough i guess that it's enclosed in brackets "[", which all the forums i read and try it either replies with a blank variable being passed or says it can't find the file at all....



Set PhaseID="[COLOR=red][B][I]Extracted PhaseID from xml[/I][/B][/COLOR]"
Set BoxID="... Read more

A:Solved: Batch File Extract TAGID to Batch Variable? weird

Read other 16 answers

Running XP SP3 Professional
Dell E1705

Periodically I get this message when I try to close MS Outlook: "The file Normal already exists. Do you want to replace the existing file?"
Then when I try to close it, Word opens, and it goes through a series of other steps I have to do to close Word. Otherwise, Word and
Outlook function properly.

The problem will start happening consistently for awhile, then go away. It has been happening for a couple of years at least. I have had
maybe three malware attacks during that time that I have successfully remedied using the help from this site. The most recent was a
Trojan or file that was named "Win32/Winwebsec". And, after following the procedures on this site I was able to clear that and have had
no other problems. Then a few days ago I started noticing this issue again.

Any help will be appreciated.

A:The file Normal already exists. Do you want to replace the existing file?

http://office.microsoft.com/en-us/word-hel...A001151452.aspxI would probably assume that Office/Word is corrupt...and uninstall/reinstall Office/Word.Louis

Read other 2 answers

I'm having a really strange problem and am wondering if anyone has encountered this. I tried to save a file and got an error on saving it, so I quit the program. The file appears as if it was never saved and doesn't show up in directory listing (GUI or cmd.exe).

However, if I try to rename any other file to that filename, it says "Cannot rename file, because file exists" and appends a number to the end. I cannot remove the number. This happens both in the GUI and cmd.exe as well.

So, basically cmd.exe del says the file does not exist, but ren says a duplicate file name exists....

Tried restarting as well.

I have no idea how to delete that "ghost" of a file so I can actually use the filename. I checked folder options and it's not a hidden file or anything like that - it just (doesn't) exist, but it does?

A:Cannot Rename File Because File (Doesn't) Exists

open disk management ..if you don't know how to find it, just right click on "computer" from the start menu and select manage, then scroll down to disk management to open it.
right click on the partition where you tried to save the file.. or C:\ if you don't have extra partitions or more than one HDD
select properties and click on the "tools" tab
click "check now" under error checking, and on the next pop up, check 'automatically fix file system errors' and press start.. select yes when asked if you would like to schedule for the next restart, then restart your computer and let the disk check run.
If that doesn't work there are other options

Read other 8 answers


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 rather keep a standard 'workflow' for other users who use the machine.

2. I'm 'ok' with batch files, but i've never tried to mirror to a different folder each time (automagically). What i'd like to do is have it backup a folder and call it "blah.1" then "blah.2" each time it is run, and then repeat once it gets to "blah.9" so it doesn't keep growing forever. I don't know how to do this.

I realise no.2 is not really for this forum, but someone might know and i might as well ask


A:How to run a batch file at logoff & some batch scripting help please

I found an answer to the logoff/shutdown:
How to schedule a task to run when shutting down windows - Stack Overflow

And the batch file folders:
robocopy - Insert current date in to destination folder structure - Stack Overflow

Read other 1 answers

Hello everyone,

So here goes the story. I had a couple of school files I needed to put into a CD-R. I inserted the CD-R into the drive and attempted to burn these files onto the CD.

I didn't know that the CD-R already had files on it. The School files were finished burning but when I opened up the CD I could only see the previous files that were on there.

The previous files that were on the CD before the school files were just random video clips, all in the avi. format. Now half of the files on the CD are still fine, they play normally on Windows Media Player. The other half of the files didn't seem to work.

I believed it was a common CD recovery issue so I attempted to recover the lost files, little did I know the files weren't even real avi. files. Here is the part that confuses me. The files that are not playable that come out to say "File Format not supported" do take up space. Some take up 1.6 mb, some take up 700 kb. It confuses me because the files take up space and claim to files yet they do not play.

When I tried using programs to fix the files it said the files were not even true avi. files. They still take up space though. As I looked farther into this problem I came to realize that the hex of the corrupted files seem to be quite different then the actual files that do work.
The good ones had "RIFF LIST or something like that" but the bad ones just had aslasga5s4f6asf15a1f... you know what I mean.

I attempted to fix this... Read more

Read other answers

I have these pictures on my computer that I just cannot open. I am not exactly sure why they would be damaged. The only thing I can remember doing is copying these files to a CD. I cannot locate the CD to get better copies or anything. Is there a way to restore them??


A:File Exists but may be damaged

Read other 9 answers

Hi, hope someone can help! I scanned a load of photos onto my friends computer (mac) and saved them on my memory stick, now i can't open them on my own computer (not a mac) keep getting a message saying "file exists but may be damaged" any ideas?????

A:File Exists But May Be Damaged


What OS are you using? If it is windows, go to control panel, select folder options and tell it to diplay extentions for file types.

What format are the pictures you are trying to view?

Read other 3 answers

I keep getting this error when I try to close my Picturetrail Editor.

How can I put the file back in the directory so I don't get this message again? Thanks!

A:File exists but not in directory

No psychic's here. What error?? Machine Specs and the version of Vista your running would also be helpful.

Read other 2 answers

I have a problem opening picture files. I had my computer cleaned up and they put everything into a back up file. Since this occurred I cannot open my previous picture files. It reads File exists but may be damaged. Can you help me figure this out, since the Computer store can't help. I am not sure if I also have to change the file format as the computor can't read the format. I have some exremely important pictures on there and I hope I have not lost them for good.

A:File exists but may be damaged?

Read other 10 answers

I was transferring videos from a memory stick pro duo when I touched the card as it was attached to my card reader. It disconnected from the computer. I reconnected it and was asked if I wanted to recover the files and it worked however the files ended up as .chk files. So I do no know how to recover those files. I would like to know how to recover those files. I also would like to know how to be able to open the MP_ROOT file. This file was damaged during the process of the loss of the files. It no longer looks like the folder it looked like before.

A:MP_ROOT file exists but cannot be opened

Try RecuCHKFiles utility from http://www.decasitodo.com/Progafi/programas/default.asp?f=4

Read other 1 answers

I was given a new computer, I'm a novice!
When I put it on all I get after the Windows 98 screen is Windows Registry or System INI file - device file - no longer exists - then - uninstalling the associated application using its uninstall or setup program

Can anyone help?

A:device file no longer exists

Read other 16 answers

Hi guys,

I can't active my PC. For some reason when I run SLUI.exe (with the 3 parameter as well) it give the Cannot Create File error. I have looked around the internet and found topics saying to run chkdsk as well as sfc /scannow. But it doesn't work. For this reason, I cannot active my Windows and I think due to this I can't use the accounts created in this PC. (Only the administrator works 100%)

What should I do to fix this? A clean install is not an option because all my Sata ports (Other than the one that I am using for HDD) are dead and I have no proper DVD ROM. Is there a way to do this without the physical repair disk or should I get an ISO and just run that?

A:SLUI.exe - Cannot Create a file that already exists (800700B7)

What command did you run?
What accounts can't you use...post errors

Read other 9 answers

I have this below .vbs script code that I use to delete two files from an FTP site. Sometimes one or both of the below files (LTRDOWN01 and CABCALLS.txt) doesn't exist, so that when the vbs code is executed an error occurs. How can I modify the code so that each Remove statement is executed *only* if the file exists?
thanks in advance,

' VBS Script Generated by CuteFTP (TM) macro recorder.
' Generated, then edited: 02/07/07 by dgr.

' Create TEConnection object
Set MySite = CreateObject("CuteFTPPro.TEConnection")

' Initialize remote server host name, protocol, port, etc.
MySite.Host = ""
MySite.Protocol = "FTP"
MySite.Port = 21
MySite.Retries = 34
MySite.Delay = 7
MySite.MaxConnections = 4
MySite.TransferType = "ASCII"
MySite.DataChannel = "DEFAULT"
MySite.AutoRename = "OFF"
' WARNING!!! SENSITIVE DATA: user name and password.
MySite.Login = "****"
MySite.Password = "***"
MySite.SocksInfo = ""
MySite.ProxyInfo = ""
' Connect to remote server
MySite.RemoteRemove "/u/sting/tapefiles/LTRDOWN01"
MySite.RemoteRemove "/u/sting/tapefiles/CABCALLS.txt"

A:.vbs script: FTP attempt to delete a file *only* if it already exists

Do you always want to "try" and delete these files even if they don't exist?
you could do this -

On error resume next
MySite.RemoteRemove "/u/sting/tapefiles/LTRDOWN01"
MySite.RemoteRemove "/u/sting/tapefiles/CABCALLS.txt"
On Error Goto 0

THe on error resume next disables the script stopping then the on error goto 0 makes it so it no longer will bypass stopping on an error.

Read other 1 answers

HiHoping someone can give me some guidance. I have had problems with Vista Home Premium SP1 crashing regularly - at least 3 times per day. Yesterday I decided to install SP2 - what a mistake. After taking hours it got stuck at Stage 3 - 75%. After following some instructions from other posts I managed to get it to starting reversing the changes - this however after hours and hours would never complete. Anyway I am now using the Windows disc system restore and this will not restore because of the following error:"Cannot create a file that already exists (0x800700B7)" I have been gradually moving to earlier restore points with no luck.Is there anyway to delete this file? or other steps I can take.Of course i'm worried that I will lose all my data - system has told me it needs to reinstall. I bought the external HDD yesterday arvo with the intention of backing first and then doing a reinstall haven't been able to do the back up as I cannot access the files - is there a way to do this?I can do basic things on my pc but when it comes to command prompts etc I need help so please be patient with me.ThanksCathy

A:System Restore won't complete - file already exists

Well the gods must have smiled upon me because after numerous reboots last night I was able to get into Windows and do a complete back up.

Sad news is pc now will not get past first screen of start up and F8 does nothing.

What next?


Read other 1 answers

I am running vista home. I keep getting a windows error message "the file exists". when I open quickbooks 2009 premier. Can't get rid of it. Any help

A:Quickbook pro 2009, windows error, file exists

hbh said:

I am running vista home. I keep getting a windows error message "the file exists". when I open quickbooks 2009 premier. Can't get rid of it. Any helpClick to expand...

if you have already tried to uninstall it from the control panel

You can try Killbox

Its free; http://www.scanwith.com/download/Pocket_KillBox.htm

Read other 1 answers

Hello.. I use search and fast-search (in the start menu) to fast-execute programs that I don't need to add shortcuts for...
but strangely some programs that I have installed and exist and working don't show up in the results.............

A:Windows search malfunctioning (can't find file that exists)

How long ago did you install the program? It takes windows a little while to add things to the index. Also not everything is indexing by default, however I recommend indexing your entire disk! It takes a while to do but makes search SOOO much more powerful.

click start
tick the disk you wish to index
wait a while

Read other 4 answers

I've encountered a bit of a hassle. I tend to save a lot of pictures, and it's getting to the point where everytime I find a new picture to save, I already have another picture with the same name. Then, of course, I need to rename or replace it. This is getting annoying because half the time I rename it, only to find out that the new name is also taken.

Is there a way to make it so windows automatically adds a number or something to the file name, so I don't have to go through the trouble of finding an available name?

A:Auto add numeric prefix/suffix to file name if same name already exists?

Come on, I can't believe that there seems to be no info on this. I have been searching everywhere for a good chunk of the day. (yeah, no life)

Read other 1 answers


we have a Lotus Notes database where we embed Excel files into a Lotus Notes Document.

Some of our users are reporting an issue where they get the message :
"Object request has not completed because the file already exists" and the users cannot open the file.

This only occures if the user tries to open the Excel sheets from his Local Lous Notes replica. When the user works from the server the file can be openend without any problems.

Does anybody know what this could be?


Atomic Wedgie

A:Lotus Notes: Object request has not completed because the file already exists

Hiya and welcome

I've moved this to Business Applications for more response

Are you still having this problem? If so, which version of Lotus Notes are you using? If you're not sure, open Lotus Notes, and click on Help | About.

Also, which version of Excel file are you embedding?

I've found this, if its outlining what you see:

Object Request Errors Occur When Opening OLE Object


Read other 1 answers

I am trying to automate a way to remove a pinned item from the start menu when the source file no longer exists.
I have found heaps of information about .lnk files or using the file verbs but as pinned icons don't work the same as simply deleting a .lnk file and the file verbs wont work as the source file no longer exists I am stuck for ideas.

Zac Avramides

Read other answers

My husband downloaded what he thought was good software from an unknown website the other day and started to get virus alerts from our ZoneAlarm firewall.  We immediately did a Malwarebytes Malware quick and full scan but it didn't find anything which surprised me.  We decided to turn off the computer while we ate dinner and then look into it more with another malware/virus scan afterwards.  After the computer was restarted, we could no longer access the Internet if the ZoneAlarm firewall and antivirus was turned on.  The network troubleshooter kept pointing to a router/gateway problem but another computer had no problems accessing the internet wireless similar to the infected computer.  The infected computer also started getting security action center message that Windows Security Center service could not turn on.  To rule out the possibility that the Zonealarm firewall was corrupted, we uninstalled the firewall making sure it was cleanly gone and re-installed it.  We still had the internet access issue problem whether we were accessing it via the wireless or Ethernet connection.  A few seconds after we would stop the ZoneAlarm firewall the network connections would start having internet connection access.  We decided to get a new free firewall and antivirus software to we could continue to resolve the issue but have security protection.  We installed Comodo Internet Security and have no problems access the internet.
W... Read more

A:Firewalls Corrupted and Unknown Virus Exists After Downloading a File

Hi Wanda, Welocme to the forum. Please download Farbar Recovery Scan Tool and save it to your desktop.Note: You need to run the version compatibale with your system. If you are not sure which version applies to your system download both of them and try to run them. Only one of them will run on your system, that will be the right version.Double-click to run it. When the tool opens click Yes to disclaimer.Press Scan button.It will make a log (FRST.txt) in the same directory the tool is run. Please copy and paste it to your reply.The first time the tool is run, it makes also another log (Addition.txt). Please attach it to your reply. 

Read other 21 answers

Norton detected a Trojan threat earlier, I followed the guidelines from the "this topic" link and then generated a HJT log. I also notice with Security Task Manager, certain processes appear and disappear periodically, i.e., lsass.exe, smss.exe, crsrr.exe and lots of other *.exe files. In "services", the start-up type of RCP is greyed-out that I don't have a choice to disable the service at start-up.

Logfile of HijackThis v1.99.1
Scan saved at 5:07:06 PM, on 05/03/2006
Platform: Windows XP SP2 (WinNT 5.01.2600)
MSIE: Internet Explorer v7.00 (7.00.5296.0000)

Running processes:
C:\Program Files\Intel\Wireless\Bin\EvtEng.exe
C:\Program Files\Intel\Wireless\Bin\S24EvMon.exe
C:\Program Files\Intel\Wireless\Bin\WLKeeper.exe
C:\Program Files\Common Files\Symantec Shared\ccSetMgr.exe... Read more

A:Download.trojan Threat - Cannot Delete B779v12[1].dll Because File No Longer Exists

Hello whyMeNow? and welcome to the BC HijackThis forum. I do not see any signs of viruses or malware in the log. It is clean.A couple of comments:- if the file b779v12[1].dll does not exist why would it need to be deleted?- I do not believe that you can stop the RCP service with CheckPoint VPN client installed. CheckPoint would be able to verify that.- I do not know how STM reports the services running. Seeing a service come and go might just be the way STM handles the services. Try taking a look at the standard windows Task Manager and see if the services come and go along with what STM is showing. If not, then that's simply how STM is reporting the information.Additional information for non- operating system software can be obtained in the All other Applications forum. Someone theremight be able to better answer those questions.Cheers.OT

Read other 1 answers

Hi all,
I need help to create windows batch file for following requirements.
1. Remove .txt and .log file format in sub folders.
2. Zip individual file inside any sub folders and give file name through command prompt. 
3. Create sub folder zip file include file zip

Read other answers

Hi all,

Any idea how to write Batch File .bat to copy file from File Sharing & FTP Hosting to local directory.

Current the File Sharing & FTP Hosting is SMARTFILE.

I don't want to use WINSCP as the connector.


A:Batch File .bat to copy file from File Sharing & FTP Hosting

Hi Chacha,

Give this batch file a try. All text in red, you should adjust before running.

@echo off
echo.lcd C:\Some\local\directory
echo.cd /Some/server/path
echo.get Some_file_to_download.txt
) > "%TEMP%\_%~n0.ftp"
ftp -s:"%TEMP%\_%~n0.ftp" ""
del "%TEMP%\_%~n0.ftp"

Read other 1 answers

Hello All.

I am trying to create a batch file that calls other batch files (device simulators).

The problem I am having is the batch file will not continue until the the call terminates, is there a way to continue it after the call (the batch only terminates after the user exits the simulator).

Thanks avamore

A:batch file: batch within batch

Welcome to TSG!

Use Start. The first set of quotes is for a title. It's needed in case the file name/command needs to be quoted, as in the 2nd example.

Start "" batch.cmd

This will open in a 2nd window. If the batch file you call doesn't use the Exit command that window may remain.
In that case use this instead:
Start "" "cmd /c batch.cmd"

Read other 1 answers


Quite often I receive a PDF file by email (e.g. a monthly bill) that I want to save with similar PDF files (e.g. former bills of the same company) in the same folder.

To avoid to write the complete file name, in the "save as..." menu I click on a former file with similar name (e.g. phone_bill_2013_January), then adapt the name (e.g. phone_bill_2013_February).

When I click "save", windows vista says "files already exists" although I modified the name.

I saw on www.vistax64.com that this problem was already discussed:

and it seems that this bug was already fixed.

How can I fix it on my computer?

Thank you very much for help.

A:Get "file already exists" on trying to save a new file (after rename)

Hello Abramo, and welcome to Vista Forums.

The issue is that it uses the original name when comparing files in the save to location. It doesn't actually get renamed until it's saved.

You should be able to use the "Copy, but keep both" option like below for this work. Worse case, you'll have to rename it again if it does keep the new name after being copied.

Hope this helps,

Read other 1 answers

I've been searching the web on how to accomplish this but am coming up empty handed so I am hoping someone here can help...

I want my batch file to read a random line from a text file into an environment variable - can this be done?

I am using Windows 2000.

A:Batch File -- Read Random Line from External File into an Environment Variable

Read other 6 answers

Dear All,

I need to create a batch file which can read the size of file(e.g. 1kb, 2kb...etc) from specific folder and detect 0kb file and convert it to text file (showing 0kb file size) with alarm.

I am not really sure how to write command for this batch file. Please help :-(

A:How to create a batch file to read size of file on specific folder path

Read other 10 answers

I am wondering if anyone can provide the equivalent to this linux script. When run against a text file with one entry per line being the name of a directory, it deletes the named directories.

On linux, I run this against the text list.
while IFS='' read -r line || [[ -n "$line" ]]; do
rm -R $line
done < "$1"

I am not sure how to make it do the same for Windows. I can do this, but I'm hoping there's a way to delete based on what's in the text file. Also, wouldn't want it to prompt for deletion of each, but to just delete.

@echo on
cd \
dir /D /N 0
for /D %%f in (XX*) do rmdir %%f /s
%comspec% /k

Thank you

Read other answers

I'm working on a batch file that will download a file I maintain, look for a string of text, and if it doesn't find the string, rename a file or folder, or change the file or folder's attributes to read-only.

I think I can handle the last part, and I already have the ftp part done, but I am having a hard time finding any good resource for the text string lookup/IF statement.

Any help is greatly appreciated. I'm new here, please excuse my ignorance if I am posting in the wrong area or violating any rules.


A:Batch file to compare text and rename file or driectory on fail

Read other 6 answers

How to create a batch file that will move files based on the file type?

My Requirement : I need a batch file to copy all .doc files in all my HardDisk to a removable disk say (Z: drive) . Can anyone make it possible using a batch file?Please...Its urgent...

A:How to create a batch file that will move files based on the file type

Download XXCopy
XXCOPY, A Versatile File Management Utility --- Boldly Extended Xcopy
This is a vastly improved and extended version of DOS XCopy
Sorry, can't remember the syntax, but its quite simple if you read the manuel carefully :-)
Put the command line in a .bat file and it will run

Read other 4 answers

I am trying to write a batch program the list the current directory files that end in *.dwg
into a file on my C drive.
I have used the following code:
dir *.dwg /b >C:FileListing.txt
start notepad C:FileListing.txt

This code only gives file names in the current directory.
I need to have a list of path and file names in the file FileListing.txt
Is there a way to do that without including subdirectories??

Thank you,

A:Solved: Batch file to list file names in current Folder.

Read other 9 answers

I created this batch file to log certain users logins. It creates a text file to log in, but doesn't populate any of the data to it. Could someone please take a look at it and see what I did wrong. I'm new to writing batch files.

Thanks in advance. Here is the code.

@echo off
set target=JDoe
if %username% == target echo %username% %date% %time% %computername% >> c:\logfile.txt

A:Solved: Batch file creates text file but does not populate data to it

target is a variable. You have to surrournd it with %% like any other variable.

C:\>set target=Squashman

C:\>if %username% == %target% echo %username% %date% %time% %computername% >> c:

C:\>type logfile.txt
Squashman Fri 05/23/2008 10:34:14.74 BUMBLE-BEE



Read other 3 answers

Hi all,

Please help!! I'm having a problem to copy some files from a folder.
My folder have lots of files and is there any way for me to write a batch file to copy only files according to "date modified"? For example last week files or yesterday files.

Please help!! Urgent!!!
Thank you.

A:Urgent!! Copy file by date modified using Batch File.

Take a look at XXCOPY: http://www.xxcopy.com/index.htm

Read other 2 answers

I want a batch to select and open a random link file in a folder i have. All the links are music videos I like to listen to, and I kind of want to just have an option for 'surprise me!'.
I can change the file names if I have to, and I have a basic batch file ability. I know the simple commands, but nothing of the variables, signs-involving commands (&%!?), etc.

Also, I want to learn a whole lot more about programming/java/batch file, so it'd be awesome if any code could be explained. Thank you, in advance

A:I need a batch file to open a random file within a certain folder/path

There's a free Windows scripting language called Autoit3 that would do this task easily using these functons:


AutoIt - AutoItScript
It has a Basic like syntax and is easy to learn.

Another popular scripting for Windows is AutoHotkey
AutoHotkey: macro and automation Windows scripting language

The syntax can be confusing but it has object support and is more powerful.

Of course there are tons of others for Windows:

Here's a list. The details for each tell which OS are supported:
Free Programming Languages - Freebyte's Guide to

Read other 5 answers

Hi Guys,

I want to make one batch file which daily copies yesterday's files from one folder & paste it to another folder.

C:/111 folder has following files.
1.zip had yesterday's date
2.zip had yesterday's date
3.zip had last sunday's date

now, when i will run batch file today, it only copies 1.zip & 2.zip & move to another folder C:/222

So C:/222 contains following
1.zip had yesterday's date
2.zip had yesterday's date

Please note , i have to run this batch file daily which should not require any changes.

Read other answers

I have a computer that is a drone specifically for an outside LED sign. This computer is designed to never shut off and doesn't have any other program on it besides Operating System and the sign software. I need to create a batch file that I can place in the "start-up" folder that will open the program (LEDStudio10) and open the file that I want to play. I have already tried multiple attempts and I was hoping someone out there in sevenforums world would be able to point me in the right direction.

A:batch file open file for program in the startup folder

Task Scheduler. Create a new/basic task. You can invoke your batch script there. This can occur after boot completes, after user logon, etc. You can set it to run daily weekly hourly, etc. You can even have it delay X (preseleted time amounts) minutes/hours after boot/logon if you want.

Task Scheduler - Create New Task

Read other 1 answers

Hi . I'm making a "PC TuneUp" project , but something is wrong . When the batch file tries to check for updates , it closes . Fortunately , i know that it closes because it doesn't find the file . But i tried everything - nothing worked . Please help !

@echo off
for /F "tokens=1" %%G in ('tasklist /V /NH /FO TABLE /FI "WINDOWTITLE eq TehDansorz"') do IF %%G==cmd.exe exit /b
if exist newest%winver%pctuneup.ver del newest%winver%pctuneup.ver
if exist %winver%pctuneup.ver del %winver%pctuneup.ver
set winver=Win7+WinVista
set ver=1.6a
set title=title TehDansorz's PC TuneUp for Win7/WinVista Version %ver%
title Requesting admin permissions ...

:: BatchGotAdmin
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Administrator privileges are required for this app to work .
echo Please click OK in the following screen .
PING -n 1 -w 600 >NUL
goto UACPrompt
) else ( goto gotAdmin )

echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"

exit /B

title Got a... Read more

A:Solved: Batch file closes when downloading version file

Read other 7 answers


I have a file in a folder on a network drive whose path is : "\\sql\imp\ssis"

I need a windows batch file that looks into the above folder for a file with a name like : "abcd_03052012_84373.txt" .

The above file name has a date embedded in it in "ddmmyyyy" format. I want that to be extracted and put into a variable or a file somewhere so that I can read that later and store into a sql table.

Please help.

A:Solved: Extract Date from File Name - Using Windows Batch File

Read other 6 answers

Hi there forum,

how do you change the Visual effects using a batch file or registry file.



A:How to change visual effects using batch file or registry file?

Hello Edward, and welcome to Ten Forums.

The links in the blue note box under OPTION FOUR in the tutorial below may be able to help with this.

Visual Effects Settings - Change in Windows 10

Read other answers

More as an alternative to twiddling my thumbs than anything else, I tried to produce a batch file that would count up the number and size of files in a folder, as well as the number and size of files with each extension. Hence it would say how many word documents I have and how much space they're taking up, etc.

I've managed to get a vaguely working model, but the output formatting is terrible (I just wanted it to say X bytes in Y "Z" Files, none of that ugly dotted variable names) and I have failed to get it to equate .htm and .html, .jpg and .jpeg, etc.

IF EXIST FTypeDst.txt ERASE FTypeDst.txt
ECHO. >FTypeDst.txt
ATTRIB +A FTypeDst.txt

ECHO Please Wait Paitently. . .


REM cycle through the current directory and subs, Increment Allnumber, Allsize, define and increment Number of * files, size of * files.
FOR /R %%F in (*) DO (
IF NOT DEFINED Number.of.%%~XF.files (SET /A Number.of.%%~XF.files = 0)
IF NOT DEFINED Size.of.%%~XF.files (SET /A Size.of.%%~X... Read more

A:Solved: File Type Distribution analysis: Batch File.

Posted via Mobile Device
You would be better off using third party software that already does this. Plenty of them out there.
I personally would check the extension of each file using the cmd extensions of a for loop. then do an if statement for each file type you want to keep track of. then use a call statement to branch to a function that adds up the file sizes and number of files.

Read other 3 answers

Hi there forum,

how do you change the Visual effects using a batch file or registry file.



Read other answers

I've come into contact with Mandriva Linux. I know of a concept called standard permissions, that it provides. It's pretty convienient. I don't exactly know how it really works under the hood or anything, and I don't need to know exactly how it works right now either, even though it's probably available.

What I want to do, in effect, is create a feature pretty close to equivelant of this feature, only for Windows XP. I want to set standard permissions using a batch file. Whenever this batch file is run as administrator it can enforce the permissions. What are these permissions it enforces? Well, what I want is for these permissions to be gotten from a text file. The syntax in no way resembles the syntax of the Linux file I'm describing.

Basically the syntax is this:
The path is the path to a file or folder in exact syntax. The mode is one of the switches that can be given for XCACLS in the Windows Resource Kit thingy. This can be replace, edit, etc. The users are the user or group to add/replace/remove/etc, and there is a comma allowed so more than one user or group is allowed to be specified. The permissions are the permissions that you can specify in the utillity.

So the first thing the script needs to do, is call some program that safely detects whether or not the filesystem is NTFS or not. If the sys... Read more

A:Get ACL permissions from a text file enforced by a batch file in Windows XP

Read other 16 answers