Computer Hope
Microsoft => Microsoft DOS => Topic started by: carlrowley1 on July 21, 2008, 06:37:09 PM
-
hello there
i have been trying this batch file example out , but what i keep getting is "system cannot find file specified" i have created i file called hope.txt in c:\batch.files
@echo off
for /f "tokens=1-5 delims=/" %%d in ("%date%") do rename "hope.txt" %%e-%%f-%%g.txt
if anyone could advise me were i am going wrong........thanks
windows xp
-
When defining your own delimiters, the space character is no longer the default. To add back the space, you need to define it as part of the delimiter pool.
@echo off
for /f "tokens=1-4 delims=/ " %%d in ("%date%") do ren "hope.txt" %%e-%%f-%%g.txt
FYI: %date% produces four parameters (ie: Mon 07/21/2008)
Good luck. 8)
-
When defining your own delimiters, the space character is no longer the default. To add back the space, you need to define it as part of the delimiter pool.
as i am just learning not quite sure what you mean , this is my batch file as it is now, i have altered it to your example.
for /f "tokens=1-4 delims=/ " %%d in ("%date%") do ren "hope.txt" %%e-%%f-%%g.txt
-
illegal characters in filename?
-
illegal characters in filename?
sorry still not sure were am going wrong
@echo off
for /f "tokens=1-4 delims=/ " %%d in ("%date%") do ren "hope.txt" %%e-%%f-%%g.txt
pause
-
does hope.txt exist where the script is looking for it?
-
yes there both in the c:\batch.files directory
-
Is C:\batch.files your default directory?
-
Is C:\batch.files your default directory?
not sure what you mean by default directory
-
If your command prompt window shows just C:\> then that is your default directory and any executable in that directory will run if you just enter the name. But if your command prompt is C:\>batch.files then C:\batch.files is your default directory and executables in C:\>batch.files will run if you just enter the executable name.
So, if your default is C:\> and hope.txt is in C:\>batch.files\ the ren in your for statement will search for it in C:\> only and it will not be found.
Try using .....ren "c:\batch.files\hope.txt"..... or cd to batch.files earlier.
Good luck
-
Try using .....ren "c:\batch.files\hope.txt"..... or cd to batch.files earlier.
tryed that still comes op with carn't find specified file
@echo off
for /f "tokens=1-4 delims=/ " %%d in ("%date%") do ren "c:\ batch.files\hope.txt" %%e-%%f-%%g.txt
pause
-
1. You have put a space after the first slash: c:\ batch.file\hope.txt. Remove it & see if it now works.
2. If not, what happens if you insert the word ECHO as shown below (What do you see on screen? - copy & paste it into your reply)
@echo off
for /f "tokens=1-4 delims=/ " %%d in ("%date%") do ECHO ren "c:\ batch.files\hope.txt" %%e-%%f-%%g.txt
pause
-
I was just moving them to the default diectory so i now have "hope.txt" and the batch file in there ....but i am still getting cannot find file
@echo off
for /f "tokens=1-4 delims=/ " %%d in ("%date%") do ren hope.txt %%e-%%f-%%g.txt
pause
-
Will you try what I asked in my last post?
-
ah right done what you said , when you click on the file now you will see
ren "c:\batch.files\hope.txt" o7-2008-.txt so dias thats it
just a silly thought but i thought it was renameing the file to o7-2008-. i said to myself whats the point in that ....................but i see what it means know...........
not quite sure how you would use this, you still have your hope.txt file but also i have a batch file that when you click on it shows you ren "c:\batch.files\hope.txt" o7-2008-.txt
-
Well, you can take the ECHO out.
I just created a folder called c:\batch.files and I put 1 file in it called hope.txt and then I ran this
ren "c:\batch.files\hope.txt" o7-2008-.txt
and now I have 1 file in there called o7-2008-.txt
so there is nothing wrong with the code.
Check that folder & file names match exactly and are all as they should be.
-
Check that folder & file names match exactly and are all as they should be.
I have just tryied this i have a folder called c:\ batch.files with hope.txt in it but when i run it i have the same problem
ren "c:\batch.files\hope.txt" o7-2008-.txt.........
-
sorry dias got to rush
i will try this again on thursday or if i can SEND YOU A PRIVATE MESSAGE .
CARN;T figure out why i have these problems, as again i started with the example i copied, and thought that would work fine.
the very first code i mentioned was the one in the example, i seem to have tryed everything , but got no where as usual ....but i try again on thursday
just a recap
i have a folder called batch.files which is in the directory c:\batch.files and i have a txt file called hope.txt in there.........................thanks
-
If this quote means what I think it means:
i have a folder called batch.files which is in the directory c:\batch.files and i have a txt file called hope.txt in there
then your path to hope.txt is not C:\batch.files\ but C:\batch.files\batch.files\ so you would have to ...ren c:\batch.files\batch.files\hope.txt...
I have the impression that the file is not being found because it is not in the correct or specified path.
Try a simple dir C:\hope.txt and dir C:\batch.files\hope.txt and dir C:\batch.files\batch.files\hope.txt to find out which path it is in.
Edit: Had another thought. If your script has already been run and has worked then Hope.txt would have been renamed. look for a file with a date as the name.
-
(http://i212.photobucket.com/albums/cc219/wiseman_012/directory-1.jpg)
Try a simple dir C:\hope.txt and dir C:\batch.files\hope.txt and dir C:\batch.files\batch.files\hope.txt to find out which path it is in.
this is what i tryed
dir c:\hope.............file not found
dir c:\batch.files\hope.txt......file not found
dir c:\batch.files\batch.files\hope.txt......system cannot find file
this is the latest one i have tryed but it still cannot find the file
[Posted by: Sidewinder Posted on: July 21, 2008, 07:04:41 PM
Insert Quote
When defining your own delimiters, the space character is no longer the default. To add back the space, you need to define it as part of the delimiter pool.
Code:
@echo off
for /f "tokens=1-4 delims=/ " %%d in ("%date%") do ren "hope.txt" %%e-%%f-%%g.txt
FYI: %date% produces four parameters (ie: Mon 07/21/2008)
/quote]
-
Based on your post, this should work but apparently doesn't:
@echo off
for /f "tokens=1-4 delims=/ " %%d in ("%date%") do ren "c:\batch.files\hope.txt" %%e-%%f-%%g.txt
Why does hope.txt have zero bytes? Is hope.txt a hidden, system or read-only file?
8)
-
Why does hope.txt have zero bytes? Is hope.txt a hidden, system or read-only file?
i ve just put a few line lines in there
i just created it for an example. so it carn't be a hidden , system file. or read only file
just don't know why it carn;t find it... its puzzeling me...because it seems so simple the hope.txt is in the c:\batch.files directory
-
quote from sidewinder
Based on your post, this should work but apparently doesn't:
Code:
@echo off
for /f "tokens=1-4 delims=/ " %%d in ("%date%") do ren "c:\batch.files\hope.txt" %%e-%%f-%%g.txt
sorry guys this is what i should have been putting :-[
@ echo off
for /f "tokens=1-4 delims=/ " %%d in ("%date%") do ren "c:\batch.files\hope.txt.txt" %%e-%%f-%%g.txt
pause
had to add another .txt on the end, so sorry if i got you all confused...these things happen if you have just started learning........ :) :-[
-
hope.txt is in the c:\batch.files directory
How do you know this?
-
had to add another .txt on the end, so sorry if i got you all confused...these things happen if you have just started learning........
I'm a little slow on the uptake, so is the problem solved?
Hopefully waiting ;)
-
yes problem solved.........thanks everyone.....until the next time
-
had to add another .txt on the end, so sorry if i got you all confused...these things happen if you have just started learning........
I'm a little slow on the uptake, so is the problem solved?
Hopefully waiting ;)
Sidewinder, I doubt if carlrowley is going to answer that question, so perhaps I will have a stab.
There never was a problem. Or rather, there was, but it was in front of the keyboard, not behind it. The OP stated that he could not rename a file called "hope.txt". Despite questions such as these he continued to maintain that this file existed and was located in a certain folder:
Check that folder & file names match exactly and are all as they should be.
However, he finally stated that the file was actually called hope.txt.txt.
One can speculate about the reasons for this, and I suspect that it may have something to do with hidden file extensions in Windows Explorer. Anyway, we all got royally led up the garden path.
-
so basically if the file was just called "HOPE" it would have worked the first time because it automatically adds the .txt , hope being a txt file
so there was a file called "hope.txt" but the computer is adding another .txt on when searching for it....thus comeing back as file not found
-
No. ""Basically" there was a file called hope.txt.txt. You seemed to think it was called hope.txt. The computer knew all along what it was called. It was you that didn't. You should uncheck "hide extensions for known file types" in Windows Explorer folder options to avoid any more "problems" like this one.
-
You should uncheck "hide extensions for known file types" in Windows Explorer folder options to avoid any more "problems" like this one.
thanks dias just done that, works fine :)
-
Anyway, we all got royally led up the garden path
Should have stopped to smell the roses. ;D
You should uncheck "hide extensions for known file types" in Windows Explorer folder options to avoid any more "problems" like this one.
Or have run a dir list on the directory and seen what the actual file names were instead of using a qualifier that did not exist.
Sometimes the simplest things....
-
Sometimes the simplest things....
Indeed.
-
Wow
I was expecting to see something like this in the post
set ydate=%date:~-4%
set mdate=%date:~4,2%
set ddate=%date:~7,2%
ren hope.txt %mdate%%ydate%.txt