Cut Command Not Working

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
btpoole
Posts: 15
Joined: 04 Sep 2015 06:28

Cut Command Not Working

#1 Post by btpoole » 04 Sep 2015 06:30

I have a fairly simple script that sets a base path, opens a txt file, reads the line, cuts the file into parts based on characters. The same script had been working fine a year ago but for some reason it will not execute now. When I run the following, the command window flashes up and closes. I can't even get a pause, timeout or wait to hold it in order to read results. The script is on Windows 7 pro. I know the path is correct and the file exist, actually it creates the nametemp file as needed but it is always empty.

set bpath="C:\server\htdocs\mydirec\input.txt"
findstr ":" %bpath% | cut -f1 -d ":" > %bpath%\data\nametemp

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Cut Command Not Working

#2 Post by Squashman » 04 Sep 2015 06:44

So you are saying this path exists?

This what your variable is expanding to.

Code: Select all

findstr ":" "C:\server\htdocs\mydirec\input.txt" | cut -f1 -d ":" > "C:\server\htdocs\mydirec\input.txt"\data\nametemp


Why would your folder path have the file name with extension in it?

Quotes need to be around the whole path. Not just part of it.

btpoole
Posts: 15
Joined: 04 Sep 2015 06:28

Re: Cut Command Not Working

#3 Post by btpoole » 06 Sep 2015 09:23

Thank you greatly, had to modify the path so with your suggestions.

Post Reply