Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: DOS Command to capture image names & output to Excel ?  (Read 6362 times)

0 Members and 1 Guest are viewing this topic.

strollin



    Adviser
  • Thanked: 84
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Guru
  • OS: Windows 10
Re: DOS Command to capture image names & output to Excel ?
« Reply #15 on: March 27, 2017, 09:20:02 AM »
It looks like we lost the OP for this thread.

patio

  • Moderator


  • Genius
  • Maud' Dib
  • Thanked: 1769
    • Yes
  • Experience: Beginner
  • OS: Windows 7
Re: DOS Command to capture image names & output to Excel ?
« Reply #16 on: March 27, 2017, 09:43:41 AM »
Quite awhile ago... 8)
" Anyone who goes to a psychiatrist should have his head examined. "

Hackoo



    Hopeful
  • Thanked: 42
  • Experience: Expert
  • OS: Windows 10
Re: DOS Command to capture image names & output to Excel ?
« Reply #17 on: March 30, 2017, 05:25:01 PM »
The OP is lost ; may be, he solved his issues on otherr side  ::)
Never mind  :P
So, i post my last modification of this batch file : ImagesFinder.bat
Code: [Select]
@echo off
Title Search for images files
mode con cols=75 lines=5 & Color 0A
REM We set the variable Folder with the function Browse4Folder
Call :Browse4Folder "Choose source folder to scan for images files" "c:\scripts"
Set "Folder=%Location%"
Rem if the variable %Folder% have a trailing back slash, we remove it !
IF %Folder:~-1%==\ SET Folder=%Folder:~0,-1%
If "%errorlevel%" EQU "0" (
echo( & echo(
echo             You choose this folder "%Folder%"
Timeout /T 2 /nobreak>nul
) else (
echo( & echo(
echo                              "%Folder%"
Timeout /T 2 /nobreak>nul & Exit
)
Rem We set the variable EXT for the extensions images to be searched by the script
Set "EXT=jpg png gif bmp tif"
REM We initialize the variable Count from zero for counting images files
SET "Count=0"
Rem Set the variable LogFile to save the information after the scanning
For %%f in (%Folder%) do set "LogFile=%~n0_%%~nf.csv"
If exist "%LogFile%" Del "%LogFile%"
Set "Msg=Please wait a while scanning for"
Setlocal Enabledelayedexpansion
For %%a in (%EXT%) Do (
Call :Scanning %%a
Call :ShowBalloonTip 'Information' 100 '"%~n0 to find images"' '"%Msg% """*.%%a""" images ..."' 'Info' 10
FOR /f "delims=" %%f IN ('dir /a-d /b /s "%Folder%\*.%%a"') DO (
Rem We increment the variable Count
SET /a "Count+=1"
rem populate the array variable list with the name of files with their extensions
set "list[!Count!]=%%~nxf"
rem populate the array variable list with the name of files without their extensions
set "listName[!Count!]=%%~nf"
rem populate the array variable listpath with the whole path of files
set "listpath[!Count!]=%%~dpFf"
Call :Scan %%~nxf
)
)
Cls
echo(
echo             Saving information into the file "%LogFile%"
echo           The Total of [%EXT%] images files(s) found is !Count!
rem Display array elements
for /L %%i in (1,1,%Count%) do (
rem save information into the LogFile.csv
echo %%i,!list[%%i]!,!listpath[%%i]!>> "%LogFile%"
)
If exist "%LogFile%" (
Start "" "%LogFile%" & exit
) else (
exit
)
::****************************************************************************
:Scanning %1
Cls
echo( & echo(
echo             %Msg% "*.%1" files ...
exit /b
::****************************************************************************
:Scan %1
Cls
echo( & echo(
echo             %Msg% "%1"
exit /b
::****************************************************************************
:ShowBalloonTip $notifyicon $time $title $text $icon $Timeout
PowerShell ^
[reflection.assembly]::loadwithpartialname('System.Windows.Forms') ^| Out-Null; ^
[reflection.assembly]::loadwithpartialname('System.Drawing') ^| Out-Null; ^
$notify = new-object system.windows.forms.notifyicon; ^
$notify.icon = [System.Drawing.SystemIcons]::%1; ^
$notify.visible = $true; ^
$notify.showballoontip(%2,%3,%4,%5); ^
Start-Sleep -s %6; ^
$notify.Dispose()
%End PowerShell%
exit /B
::*****************************************************************************
:Browse4Folder
set Location=
set vbs="%temp%\_.vbs"
set cmd="%temp%\_.cmd"
for %%f in (%vbs% %cmd%) do if exist %%f del %%f
for %%g in ("vbs cmd") do if defined %%g set %%g=
(
    echo set shell=WScript.CreateObject("Shell.Application"^)
    echo set f=shell.BrowseForFolder(0,"%~1",0,"%~2"^)
    echo if typename(f^)="Nothing" Then 
    echo wscript.echo "set Location=Dialog Cancelled"
    echo WScript.Quit(1^)
    echo end if
    echo set fs=f.Items(^):set fi=fs.Item(^)
    echo p=fi.Path:wscript.echo "set Location=" ^& p
)>%vbs%
cscript //nologo %vbs% > %cmd%
for /f "delims=" %%a in (%cmd%) do %%a
for %%f in (%vbs% %cmd%) do if exist %%f del /f /q %%f
for %%g in ("vbs cmd") do if defined %%g set %%g=
goto :eof
::******************************************************************************