@echo off
rem Set the folder where the images are stored
set "E:\Images\NEneNe"
rem Loop through all files in the folder
for /f "delims=" %%i in ('dir /b "%folder%\*.gif" "%folder%\*.png"') do (
rem Generate the .jpg file name
set "jpg_file_name=%%~ni.jpg"
rem Check if a .jpg file with the same name already exists in the folder
if not exist "%folder%\%jpg_file_name%" (
rem Convert the image to .jpg and save it in the folder
magick convert "%%i" -colorspace RGB "%folder%\%jpg_file_name%"
rem Check if there are duplicate files
if exist "%folder%\%jpg_file_name%" (
rem Add a -1 to the file name
set /a cnt=1
set "jpg_file_name=%%~ni-%cnt%.jpg"
rem Check if there are still duplicate files
if exist "%folder%\%jpg_file_name%" (
rem Add 1 to the -1 in the file name
set /a cnt=cnt+1
set "jpg_file_name=%%~ni-%cnt%.jpg"
)
rem Convert the image to .jpg and save it in the folder
magick convert "%%i" -colorspace RGB "%folder%\%jpg_file_name%"
)
)
)
Only one way to find outI heard ChatGPT could write code so I made it create a script that can find any png and gif files in a folder and convert those into jpg files while ignoring any jpg files already in the folder on Windows Powershell, question is though would it actually work?
Here's the code:
Code:@echo off rem Set the folder where the images are stored set "E:\Images\NEneNe" rem Loop through all files in the folder for /f "delims=" %%i in ('dir /b "%folder%\*.gif" "%folder%\*.png"') do ( rem Generate the .jpg file name set "jpg_file_name=%%~ni.jpg" rem Check if a .jpg file with the same name already exists in the folder if not exist "%folder%\%jpg_file_name%" ( rem Convert the image to .jpg and save it in the folder magick convert "%%i" -colorspace RGB "%folder%\%jpg_file_name%" rem Check if there are duplicate files if exist "%folder%\%jpg_file_name%" ( rem Add a -1 to the file name set /a cnt=1 set "jpg_file_name=%%~ni-%cnt%.jpg" rem Check if there are still duplicate files if exist "%folder%\%jpg_file_name%" ( rem Add 1 to the -1 in the file name set /a cnt=cnt+1 set "jpg_file_name=%%~ni-%cnt%.jpg" ) rem Convert the image to .jpg and save it in the folder magick convert "%%i" -colorspace RGB "%folder%\%jpg_file_name%" ) ) )
@Ral
Shit, I just deleted the forumOnly one way to find out
I can muster something up.I see, so then do you know the actual way to write a script preferably on Windows Powershell or CMD Prompt, that can look through a folder and convert image files to jpg, while ignoring jpg files already in the folder? And adding a postfix to any duplicate file names so that the files doesn't get overwritten?
Because I've been trying to use local apps and online converters but they either run out of memory or crash.
Um. a lot.I can muster something up.
1. How many files are you trying to convert at the moment?
No, no subdirectories.2. Are they sorted by folders?
Yes3. Do you want it to be recursive so that it finds, and coverts said files
No.within subdirectories of the parent folder?
If it's free sure.You'll likely want an image converter like ImageMagick or I'm sure there are other image converter programs that we can use for this.
Gotchu.Um. a lot.
No, no subdirectories.
Yes
No.
If it's free sure.
Also sorry for asking for more, but is it possible to make it so the script can find .bin files and delete them? Cause there are a bunch in my folder cause downloading the files went wrong I think.
What if an image has "bin" in its name? Not .bin as an extension. Would it think that as a bin file and delete it? Or would it just be looking through extensions?Gotchu.
It's fairly easy to work with dummy files as if you're searching by file extension, you can enable Windows to show you file extensions in the folder settings. From there you can pretty much create text files, change the extension to .bin, .gif, etc, and that's how you will go about testing if the script meets your needs.
Through extensions, as you'll most likely use a wildcard such as "*" before the extension as the example provided shows in the beginning of the for loop. I'll have some code for you by the end of the week if not sooner and if you need a breakdown of how I came to write it, let me know.What if an image has "bin" in its name? Not .bin as an extension. Would it think that as a bin file and delete it? Or would it just be looking through extensions?
No actually, this to train an ai.This is to decrease the size of a hentai folder isn't it?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?