File Not Found

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
JelloOfTheMoon
Posts: 11
Joined: 30 Jul 2013 20:07

File Not Found

#1 Post by JelloOfTheMoon » 30 Jul 2013 20:13

Here is my code:

Code: Select all

@TITLE Backer-upper
MODE CON: COLS=200 LINES=30
:loop
SET timestamp=%date:/=-%-%time::=-%
PING 1.1.1.1 -n 1 -w 1000 > NUL
XCOPY "world\*" "%~dp0\backups\worlds\world_backup_%timestamp%" /i /s
XCOPY "ops\*" "%~dp0\backups\lists\ops_%timestamp%" /s /c
goto loop
@pause


When I run it, the 'world' files copy perfectly, but the text file 'ops' doesn't. It shows the directories and then:

Code: Select all

File not found - *
0 File(s) copied


Please, please, please does anyone know what could be causing this? Is the problem here?
Thank you so, so, so much.

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

Re: File Not Found

#2 Post by foxidrive » 30 Jul 2013 21:16

is it a text file called ops?

If so then remove the \* after ops and ops is assumed to be in the current working directory.

JelloOfTheMoon
Posts: 11
Joined: 30 Jul 2013 20:07

Re: File Not Found

#3 Post by JelloOfTheMoon » 30 Jul 2013 22:45

Thanks much, but now it says

Code: Select all

File not found - ops


Edit: I added the .txt extension as well as doing what you said, but not its giving me a cyclic error (cannot perform a cyclic copy).
Edit 2: I removed the /s switch and that fixed the cyclic error, but now it asks if the file is a file or directory. Is there a way to automatically set this?
Edit 3: I added the switch /e but that gives me the cyclic error again.
Edit 4: Solved it. Using the COPY command rather than XCOPY will suppress the 'file or directory' prompt.

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

Re: File Not Found

#4 Post by foxidrive » 31 Jul 2013 00:49

All fixed then. Wunderbar.

JelloOfTheMoon
Posts: 11
Joined: 30 Jul 2013 20:07

Re: File Not Found

#5 Post by JelloOfTheMoon » 31 Jul 2013 00:53

Not quite. Now the problem has evolved. I need to read line five from a text file and I would prefer to do that without using a loop. Is that possible? If not, how do I do a loop?

This is what I was looking at, but it only gets line one.

Code: Select all

set /p var=<test.txt

Dragokas
Posts: 43
Joined: 30 Jul 2013 09:42
Location: Ukraine, USSR
Contact:

Re: File Not Found

#6 Post by Dragokas » 31 Jul 2013 01:43

Hello, JelloOfTheMoon.

Try this :)

Code: Select all

(set /p x=& set /p x=& set /p x=& set /p x=& set /p st=) < test.txt
echo %st%


Best regards, Alex.

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

Re: File Not Found

#7 Post by foxidrive » 31 Jul 2013 02:21

That's clever, Alex.

Dragokas
Posts: 43
Joined: 30 Jul 2013 09:42
Location: Ukraine, USSR
Contact:

Re: File Not Found

#8 Post by Dragokas » 31 Jul 2013 02:52

foxidrive, thanks : )
P.S. The idea of that code construction belong to guy with neakname FraidZZ.

So, I continue if it likes.
Another one - with cycle, but it uses not for iterating lines, just to parse 2-nd token and save output to variable:

Code: Select all

@echo off
SetLocal EnableExtensions

For /F "tokens=1* delims=]" %%A in ('find /N /V "" ^< "st.txt" ^| findstr /B "\[5\]"') do set st=%%B
echo %st%

pause
Exit /B

brinda
Posts: 78
Joined: 25 Apr 2012 23:51

Re: File Not Found

#9 Post by brinda » 31 Jul 2013 05:58

Alex/FraidZZ,
thanks. this is short and different method. can get any line from top.

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

Re: File Not Found

#10 Post by Squashman » 31 Jul 2013 06:33

Dragokas wrote:Hello, JelloOfTheMoon.

Try this :)

Code: Select all

(set /p x=& set /p x=& set /p x=& set /p x=& set /p st=) < test.txt
echo %st%


Best regards, Alex.

Pretty sure we have iterations of that code similar to that on the forums just not with the Conditional Operator. I have seen it done both of these ways.

Code: Select all

(set /p x=
set /p x=
set /p x=
set /p x=
set /p st=)<test.txt
echo %st%

<test.txt (set /p x=
set /p x=
set /p x=
set /p x=
set /p st=)
echo %st%

JelloOfTheMoon
Posts: 11
Joined: 30 Jul 2013 20:07

Re: File Not Found

#11 Post by JelloOfTheMoon » 31 Jul 2013 08:37

I cannot express my gratitude! So very awesome. Thanks much!

Edit: I just realised I need to get a certain string from that line. I'm also open to loops now, I understand them (more or less). It will always be on line five, and always immediately after:

Code: Select all

level-name=

Is this possible?

Dragokas
Posts: 43
Joined: 30 Jul 2013 09:42
Location: Ukraine, USSR
Contact:

Re: File Not Found

#12 Post by Dragokas » 31 Jul 2013 10:18

level-name=12345
Do you mean you needs this part?
12345

JelloOfTheMoon
Posts: 11
Joined: 30 Jul 2013 20:07

Re: File Not Found

#13 Post by JelloOfTheMoon » 31 Jul 2013 12:07

yes

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

Re: File Not Found

#14 Post by Squashman » 31 Jul 2013 12:26

Does the line start with level-name=?

JelloOfTheMoon
Posts: 11
Joined: 30 Jul 2013 20:07

Re: File Not Found

#15 Post by JelloOfTheMoon » 31 Jul 2013 13:28

yes. The line is

Code: Select all

level-name=world

but 'world' can be changed, so I want the code to work on anything that would replace it

Post Reply