Page 1 of 2
File Not Found
Posted: 30 Jul 2013 20:13
by JelloOfTheMoon
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.
Re: File Not Found
Posted: 30 Jul 2013 21:16
by foxidrive
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.
Re: File Not Found
Posted: 30 Jul 2013 22:45
by JelloOfTheMoon
Thanks much, but now it says
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.
Re: File Not Found
Posted: 31 Jul 2013 00:49
by foxidrive
All fixed then. Wunderbar.
Re: File Not Found
Posted: 31 Jul 2013 00:53
by JelloOfTheMoon
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.
Re: File Not Found
Posted: 31 Jul 2013 01:43
by Dragokas
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.
Re: File Not Found
Posted: 31 Jul 2013 02:21
by foxidrive
That's clever, Alex.
Re: File Not Found
Posted: 31 Jul 2013 02:52
by Dragokas
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
Re: File Not Found
Posted: 31 Jul 2013 05:58
by brinda
Alex/FraidZZ,
thanks. this is short and different method. can get any line from top.
Re: File Not Found
Posted: 31 Jul 2013 06:33
by Squashman
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%
Re: File Not Found
Posted: 31 Jul 2013 08:37
by JelloOfTheMoon
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:
Is this possible?
Re: File Not Found
Posted: 31 Jul 2013 10:18
by Dragokas
level-name=12345
Do you mean you needs this part?
12345
Re: File Not Found
Posted: 31 Jul 2013 12:07
by JelloOfTheMoon
yes
Re: File Not Found
Posted: 31 Jul 2013 12:26
by Squashman
Does the line start with level-name=?
Re: File Not Found
Posted: 31 Jul 2013 13:28
by JelloOfTheMoon
yes. The line is
but 'world' can be changed, so I want the code to work on anything that would replace it