Computer Hope
Microsoft => Microsoft DOS => Topic started by: Handler on April 17, 2017, 03:04:03 PM
-
Hello!
Fairly simple problem that I can't figure out. :(
I managed to get this far :
for %F in ("e:\*") do @echo %F=:=%~zF
Which does what I want. The =:= is there just so I have something to explode off of when reading this in to a PHP script. Now I tried using the > filename.txt to direct the output to a file but in the end I would only get the name of the that file "filename.txt" and it's file size.
This will be my one learned thing for the day! ;D
Thanks for any and all help, super appreciated!
Dave
-
Hi ;)
So what is the result of those commands ?
for %F in ("e:\*") do @echo %F=:=%~zF > e:\File_Size1.txt
and this :
for %F in ("e:\*") do @echo %F=:=%~zF >> e:\File_Size2.txt
-
Sorry I didn't respond earlier but yes it seems that second option does work and lists all the files in that directory the first just shows the last file. Which leads me to believe it just kept over writing the file every time. Ugh!
Thanks for getting me un-stuck! ;D
-
As you found, a single chevron > overwrites the file while double chevrons append. I've found it works best to write the batch file in such a way that the first file echoed to the file is done with one >, while the rest are echoed with two >>. That way, I get a new file each time but I still get everything.
You could also just delete the file first, then use >> to do the echoing.