For \F not working --- Revert immediately please

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
pratik151192
Posts: 11
Joined: 25 Sep 2014 23:25

For \F not working --- Revert immediately please

#1 Post by pratik151192 » 06 Oct 2014 22:04

Hi,

I have a bat file in which I am extracting the name of all the .txt files from another file. This operation was previously done using debug commands,etc. but for Windows NT I am using for loops with switch commands.

Code: Select all

:: @echo off
:: This batch file sets the file created date into
:: the environment under Win9x. This kind of thing
:: is often needed by scripts trying to determine
:: whether or not to update a file.
:: It uses the DEBUG command to extract the created
:: date from the output of the DIR command. The output
:: of the Win9x DIR command is like this:
:: TEST     BAT           582  04-23-00 11:02p test.bat
:: Notice the date starts on the 29th character (hex 1D)
:: so we replace the first 28 characters (hex 1C) with
:: spaces (hex 20) with this line - "f 100 l 1c 20"
:: Then enter the string "set created=" just before
:: the date at the 16th character (hex 10) so that
:: 16 (our start point) added to the lenghth of
:: "set created=" (12 characters) ends us at the 28th
:: character. Notice also the created date ends at
:: character 36 (hex 24), so we trim things at that
:: point (just after the "rcx" line by setting the
:: file length to 24 hex. After that, just we just
:: Write the file to disk ("w") and quit ("q").
:: If you have NT, you should learn how to use the
:: switches in the FOR command so you can avoid this!
:: The use of DEBUG to extract data from lines is only
:: needed under Win9x.

if [%1]==[] goto HELP
goto RUN

:HELP
cls
echo You must supply a file name as an argument.
goto DONE

:RUN
set fname=
for /F “tokens=1-11,* delims=/. “ %%A in (‘type  %1^| find “txt”‘) do set “fname=%%J %%K”
echo %fname%
:: pause
>  scriptt.bat echo set fn=%%1
>> scriptt.bat echo set extn=%%2
>> scriptt.bat echo %fn% %extn%
call scriptt.bat %fname%
del scriptt.bat

:DONE


I get the following error when this script runs:

1-11 was unexpected at this time. Process Exit Code 255. The step failed.

Please help.

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: For \F not working --- Revert immediately please

#2 Post by foxidrive » 06 Oct 2014 22:34

Your double quotes aren't real double quotes, for one.

pratik151192
Posts: 11
Joined: 25 Sep 2014 23:25

Re: For \F not working --- Revert immediately please

#3 Post by pratik151192 » 06 Oct 2014 22:38

yes, I have reviewed that. I do not know why when I post it here, it appears slanting

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: For \F not working --- Revert immediately please

#4 Post by foxidrive » 06 Oct 2014 23:00

pratik151192 wrote:yes, I have reviewed that. I do not know why when I post it here, it appears slanting


If you copy and pasted the code then you probably aren't familiar with ascii codes and hex viewers.

Load the code into a text editor in MSDOS mode and examine them.

ShadowThief
Expert
Posts: 987
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: For \F not working --- Revert immediately please

#5 Post by ShadowThief » 07 Oct 2014 01:32

Copying your slanted quotes reproduces your error. You MUST be using the double quotes that appear when you press SHIFT and the ' button that is next to enter.

Endoro
Posts: 244
Joined: 27 Mar 2013 01:29
Location: Bozen

Re: For \F not working --- Revert immediately please

#6 Post by Endoro » 07 Oct 2014 12:13

ShadowThief wrote:when you press SHIFT and the ' button that is next to enter.

It depends on your local keybord. It appears here when I press SHIFT and 2 :D

Compo
Posts: 506
Joined: 21 Mar 2014 08:50

Re: For \F not working --- Revert immediately please

#7 Post by Compo » 07 Oct 2014 12:16

…also is this not more like what you wanted?

Code: Select all

@Echo Off
If Not [%1]==[] GoTo RUN
Echo You must supply a file name as an argument.
GoTo DONE

:RUN
(Set fname=)
For /F "Tokens=10,11 Delims=/. " %%A In ('Find "txt"^<%1') Do (
   Set fname=%%A %%B)
If Not Defined fname GoTo DONE
Echo %%fname%%=%fname%
>scriptt.bat (Echo Set fn=%%1
   Echo Set extn=%%2
   Echo Echo %%%%fn%%%% %%%%extn%%%%=%%fn%% %%extn%%)
Call scriptt.bat %fname%
Del scriptt.bat

:DONE
Pause
…minus the commented lines

pratik151192
Posts: 11
Joined: 25 Sep 2014 23:25

Re: For \F not working --- Revert immediately please

#8 Post by pratik151192 » 08 Oct 2014 02:09

Thanks for the solutions and suggestions. This problem got solved

Post Reply