Search found 187 matches

by Fawers
16 Apr 2012 16:01
Forum: DOS Batch Forum
Topic: read file names and call bat files [SOLVED]
Replies: 5
Views: 1715

Re: newbie needs help - read file names and call bat files

I don't know if I understood it correctly, but here it goes. Untested: @echo off set "prefix=prefix1 prefix2 prefix3" ::set "prefix" to all your file prefixes; each one must be separated by a blank space ::i'll use prefix1, prefix2 and prefix3 as an example for %%a in (%prefix%) ...
by Fawers
15 Apr 2012 08:54
Forum: DOS Batch Forum
Topic: was unexpected at this time???
Replies: 5
Views: 16849

Re: was unexpected at this time???

That line: C:\test> IF EQU 0 ( You are trying to compare <nothing> to 0. That's why it's returning an error. You've probably used a variable that didn't expand to anything at all. To avoid this problem, enclose both variable and 0 in anything you want. I like to use brackets: if [%var%] == [0] There...
by Fawers
15 Apr 2012 08:33
Forum: DOS Batch Forum
Topic: was unexpected at this time???
Replies: 5
Views: 16849

Re: was unexpected at this time???

Change the first line to ::@echo off (so it won't disable echoing), run it again and copy/paste the last lines.
by Fawers
14 Apr 2012 14:37
Forum: DOS Batch Forum
Topic: Why does %errorlevel% not work with an "if" statement?
Replies: 7
Views: 2984

Re: Why does %errorlevel% not work with an "if" statement?

MKANET wrote:ohhhhhhhhhh... duh... I forgot to switch the % to !

Heheh. Mistakes are common when writing codes.
We just take longer to realize what they are because, unlike C, Batch scripts are interpreted in real time; they don't point us exactly where an error occurs.
by Fawers
14 Apr 2012 14:21
Forum: DOS Batch Forum
Topic: Why does %errorlevel% not work with an "if" statement?
Replies: 7
Views: 2984

Re: Why does %errorlevel% not work with an "if" statement?

if %BKfiledate%==%date% ( find /c "<errors>0</errors>" %recentBK% if %errorlevel% equ 1 set today=failed echo %today% ) Once you have it inside parenthesis to let the script know it needs to execute this code block you need to use delayed expansion. ::added: setlocal EnableDelayedExpansio...
by Fawers
14 Apr 2012 10:26
Forum: DOS Batch Forum
Topic: Unzip or Unrar files with Batch file?
Replies: 21
Views: 15211

Re: Unzip or Unrar files with Batch file?

ivar75, This is tested. It works with WinRAR command line application for *.rar files and 7-Zip command line application for *.7z and *.zip files. @echo off setlocal EnableDelayedExpansion set rarpath= set 7zpath= ::If it is a .rar file that you want to unrar, set ¦rarpath¦ to rar.exe ::rar.exe can ...
by Fawers
14 Apr 2012 09:30
Forum: DOS Batch Forum
Topic: Finding .txt files of certain name length
Replies: 12
Views: 2763

Re: Finding .txt files of certain name length

setlocal EnableDelayedExpansion for /R C:\ %%f in (*.txt) do ( set "name=%%~Nf" if "!name:~7,4!" == ".txt" echo %%~Nf ) Mate, careful. This code won't find .txt at [position] !name:~7,4! unless you set name to %%~N X f . set "name=%%~NXf"
by Fawers
13 Apr 2012 10:43
Forum: DOS Batch Forum
Topic: Unzip or Unrar files with Batch file?
Replies: 21
Views: 15211

Re: Unzip or Unrar files with Batch file?

Question remains about the subfolders/files: should they be overwritten or not? Saso I'm sure that could be a problem. 7z and WinRAR standard command line applications ask whether user wants to overwrite files or not. They even ask for a password if they found out that the files are encrypted. I'm ...
by Fawers
12 Apr 2012 20:53
Forum: DOS Batch Forum
Topic: Unzip or Unrar files with Batch file?
Replies: 21
Views: 15211

Re: Unzip or Unrar files with Batch file?

FWIW there is also the completely free and standalone unrar.exe (m) which requires no money, no installation, and has its source code available. But does it support command line operations? 7z.exe requires 7z.dll too. The self-contained 7za.exe (in the 'extra' package at m) supports fewer formats n...
by Fawers
12 Apr 2012 19:03
Forum: DOS Batch Forum
Topic: Unzip or Unrar files with Batch file?
Replies: 21
Views: 15211

Re: Unzip or Unrar files with Batch file?

I figured a way to unzip files with batch. On my previous code, I couldn't help but notice that it wouldn't unzip files; it will only unrar them. Do you have 7zip? If you don't, look forward to downloading it, for it has too a command line based file named "7z.exe". I tested it and it work...
by Fawers
12 Apr 2012 11:27
Forum: DOS Batch Forum
Topic: Macros for CMD?
Replies: 2
Views: 901

Re: Macros for CMD?

Thanks!
by Fawers
12 Apr 2012 11:06
Forum: DOS Batch Forum
Topic: Unzip or Unrar files with Batch file?
Replies: 21
Views: 15211

Re: Unzip or Unrar files with Batch file?

You were so anal when all you had to say was 'Oh, I wasn't very clear, was I?. If this is English 101 then please tell me where you used the word 'assuming'? All I had to say was that. And all you had to say was, "Oh, you assumed it, didn't you?". Oh, the irony. Was all that really necess...
by Fawers
12 Apr 2012 11:00
Forum: DOS Batch Forum
Topic: Unzip or Unrar files with Batch file?
Replies: 21
Views: 15211

Re: Unzip or Unrar files with Batch file?

Tested: @echo off set rarpath= ::rarpath should contain the full - or short - path of rar.exe file inside WinRAR folder ::assuming you've got WinRAR, of course ::place this batch file in the same folder as your .rar files ::files will be extracted into this same folder ::WinRAR command line works we...
by Fawers
12 Apr 2012 10:34
Forum: DOS Batch Forum
Topic: New Batch scripter, Please help.
Replies: 11
Views: 2217

Re: New Batch scripter, Please help.

Dewars wrote:Batch Script
Press any key to continue . . .


It means the folder was created successfully.
by Fawers
12 Apr 2012 10:30
Forum: DOS Batch Forum
Topic: Unzip or Unrar files with Batch file?
Replies: 21
Views: 15211

Re: Unzip or Unrar files with Batch file?

There should be a file called "rar.exe" in your %programfiles%\WinRAR folder. CD (or PUSHD) your DOS window into it and type rar.exe /? It'll return all the command line parameters to you. Done that, you shall then tell us what exactly you want in your batch file. If this is English 101 t...