Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Marrone
- Posts: 2
- Joined: 07 Jul 2009 08:36
#1
Post
by Marrone » 07 Jul 2009 08:42
What I have to do to make this code works?
Code: Select all
for /d %%d in (%APPDATA%\Mozilla\Firefox %LOCALAPPDATA%\Mozilla\Firefox) do (
if exist %%d (
for /r %%f in (%%d\*.sqlite) do (
set name=%%~nf .
set name=!name:~0,14!
set size=%%~zf
echo.!name! !size!
)
)
)
Thanks anyway.
PS: I DON'T WANT VBScript.
-
RElliott63
- Expert
- Posts: 80
- Joined: 04 Feb 2009 10:03
#2
Post
by RElliott63 » 07 Jul 2009 09:24
Marrone,
What's the error you're receiving? If the %AppData% or %LocalAppData% have spaces in it, then you won't get the whole path presented in %%d, thus not finding the actual folder you're looking for.
You might want to use quotes and remove them with %%~D as needed.
-Rick
-
Marrone
- Posts: 2
- Joined: 07 Jul 2009 08:36
#3
Post
by Marrone » 07 Jul 2009 14:03
Rick,
The environment variables actually works, but I'll quote them to avoid unintentional problems. Thanks for this tip.
The problem I'm giving is that the nested
for doesn't working, even that it's apparently Ok. The
if statement passes, but the nested
for doesn't iterate over.
Thanks anyway.
-
RElliott63
- Expert
- Posts: 80
- Joined: 04 Feb 2009 10:03
#4
Post
by RElliott63 » 07 Jul 2009 23:59
OK, try this... it should help you get somewhere with it...
Code: Select all
@Echo Off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
for /d %%d in (%APPDATA%\Mozilla\Firefox %LOCALAPPDATA%\Mozilla\Firefox) do (
if exist %%d\*.sqlite (
for /f %%f in ('Dir /b %%d\*.sqlite') do (
set name=%%~nf .
set name=!name:~0,14!
set size=%%~zf
echo.!name! !size!
)
) Else (Echo Files do not exist!)
)
-
avery_larry
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
#5
Post
by avery_larry » 08 Jul 2009 11:17
I believe Relliott got it right -- the spaces in %appdata% and/or %localappdata% are causing problems -- unless you don't have spaces in those paths. Add to that the fact that you can't use quotes inside the basic for loops and you'll be stuck. Try this:
Code: Select all
@Echo Off
for %%d in ("%APPDATA%\Mozilla\Firefox" "%LOCALAPPDATA%\Mozilla\Firefox") do (
if exist %%d (
for /f "usebackq tokens=* delims=" %%f in (`dir /b /s "%%~d\*.sqlite"`) do (
echo.%%~nf %%~zf
)
) Else (
Echo %%d does not exist!
)
)
Though I don't quite understand the purpose of the else statement--since you apparently want to search the subfolders for *.sqlite . . .