BAT File Command Help

Sorry that I'm a little lost, what is the current issue? You are using it on a server and the script is reading the current folder (the one the script is sitting in) as "Windows" rather than its real name? Is that it?
 
Sorry that I'm a little lost, what is the current issue? You are using it on a server and the script is reading the current folder (the one the script is sitting in) as "Windows" rather than its real name? Is that it?
That is my understanding, when the O/S is Windows Server something.
 
@theDBguy's solution works for me.
I saved the bat in a network drive of our domain controller and executed it from a client PC. The text file with the folder name was created on desktop.

2025-04-26_19-37-36.jpg


Edit : Moved the bat to a sub sub sub folder. Still it's perfect.
 
Last edited:
Sorry that I'm a little lost, what is the current issue? You are using it on a server and the script is reading the current folder (the one the script is sitting in) as "Windows" rather than its real name? Is that it?

Yes. The BAT file appends "Windows" to the file name instead of the actual folder name.
 
Yes. The BAT file appends "Windows" to the file name instead of the actual folder name.
Okay. I wasn't sure which script it was. Glad you got everything working the way you want.
 
Okay. I wasn't sure which script it was. Glad you got everything working the way you want.

Once I changed the folder location your script works 100%. If I understand the code correctly it writes the file names into the text file one at a time. The folders I want to use these on contain product images. Some of them have over 36k images in them. It takes a little bit for the script to add all 36k file names into the text file.

The BAT file is instant but it appends "Windows" to the text file name instead of the folder name. Because it works faster I would like to use the BAT file.

I am not complaining, just stating the state of things. I am grateful for all the help.
 
Once I changed the folder location your script works 100%. If I understand the code correctly it writes the file names into the text file one at a time. The folders I want to use these on contain product images. Some of them have over 36k images in them. It takes a little bit for the script to add all 36k file names into the text file.

The BAT file is instant but it appends "Windows" to the text file name instead of the folder name. Because it works faster I would like to use the BAT file.

I am not complaining, just stating the state of things. I am grateful for all the help.
Yeah, unfortunately VBScript (unlike VBA) doesn't have the DIR function, which would have been ~instantaneous too.
I can definitely understand preferring the BAT in this situation for sure 👍
 
Another question on this.

Here is what I am using:

dir "%~dp0" /b > "%USERPROFILE%\Desktop\list.txt"

I am dealing with images. Is there a command that will give me the directory and the images resolution?
 
The image resolution would be an extended file attribute that is part of the file's metadata. BAT files typically don't operate at that level. Using VBA you can do it but given the limits of VBS, not sure of how you would do that. I haven't played with VBS in a LONG while and never used it a lot anyway.
 
Another question on this.

Here is what I am using:

dir "%~dp0" /b > "%USERPROFILE%\Desktop\list.txt"

I am dealing with images. Is there a command that will give me the directory and the images resolution?

Save this VBScript in the same folder as your batch file:
Code:
Set img = CreateObject("WIA.ImageFile")
img.LoadFile WScript.Arguments(0)

Dim fso, logFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set logFile = fso.OpenTextFile(WScript.Arguments(1), 8, True)

logFile.WriteLine WScript.Arguments(0)
logFile.WriteLine "  Width: " & img.Width & " px"
logFile.WriteLine "  Height: " & img.Height & " px"
logFile.WriteLine ""
logFile.Close

Edit your BAT File something like:
Code:
@echo off
setlocal enabledelayedexpansion

set "imageFolder=C:\Path\To\Images"
set "logFile=%imageFolder%\ImageDimensions.txt"

echo Image Dimension Log > "%logFile%"
echo ==================== >> "%logFile%"
echo. >> "%logFile%"

for %%F in ("%imageFolder%\*.jpg" "%imageFolder%\*.png") do (
    cscript //nologo GetImageDimensions.vbs "%%F" "%logFile%"
)

echo Done. Log saved to: %logFile%
pause

Output Example (ImageDimensions.txt)

Code:
C:\Path\To\Images\camera1.jpg
  Width: 1920 px
  Height: 1080 px

C:\Path\To\Images\snapshot2.png
  Width: 1280 px
  Height: 720 px
 

Users who are viewing this thread

Back
Top Bottom