Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REM #######################################################################
- REM #### Folder Contents List Script for Notepad++ v1 by Valerie Vixen ####
- REM #######################################################################
- REM ### Put this in your %PATH% somewhere or add its location to %PATH% ###
- REM #######################################################################
- CLS
- @ECHO Off
- SETLOCAL EnableDelayedExpansion
- SET arguments=%*
- RD /S /Q %temp%\folder-list\ 2>nul
- MKDIR %temp%\folder-list
- :check
- REM Checking to see if arguments were passed.
- IF NOT DEFINED %1 [ GOTO root ]
- GOTO definedfolder
- :root
- for %%N in (.) do set WorkingFolderName=%%~nxN
- @ECHO No arguments passed. Creating file in current working folder (%WorkingFolderName%).
- SET ListFile=%temp%\folder-list\%WorkingFolderName%.FolderContents.txt
- DEL /F /Q "%cd%\%WorkingFolderName%.FolderContents.txt" 2>nul
- REM Cleaning up so the index file itself doesn't get listed, if it already exists.
- FOR %%F IN (*) DO (ECHO %%~nxF>>"%ListFile%")
- REM Boom! Send that list of files to the text file in TEMP!
- robocopy /NS /NC /NFL /NDL /NJH /NJS /J /MT:2 %temp%\folder-list "%cd%" 2>nul
- SET ListFile=%cd%\%WorkingFolderName%.FolderContents.txt
- GOTO cleanup
- REM Move the list file to the proper folder and head to the endgame.
- :definedfolder
- CLS
- CALL DeQuote arguments
- REM Removing quotes from arguments.
- for %%N in ("%arguments%\.") do set WorkingFolderName=%%~nxN
- for /d %%D in ("%arguments%\.") do set WorkingFolder=%%~fD
- SET ListFile=%temp%\folder-list\%WorkingFolderName%.FolderContents.txt
- REM Defining important stuff
- IF EXIST "%WorkingFolder%" GOTO verified
- REM Does the folder defined by the user even exist? If no, then fail.
- REM Could also fail if folder isn't writeable.
- @ECHO Oops! no such folder as %WorkingFolderName%
- GOTO :eof
- :verified
- DEL /F /Q "%WorkingFolder%\%WorkingFolderName%.FolderContents.txt" 2>nul
- REM Cleaning up so the index file itself doesn't get listed, if it already exists.
- for %%F in ("%WorkingFolder%\*") do (echo %%~nxF>>"%ListFile%")
- REM Boom! Send that list of files to the text file in TEMP!
- robocopy /NS /NC /NFL /NDL /NJH /NJS /J /MT:2 %temp%\folder-list "%WorkingFolder%" 2>nul
- SET ListFile=%WorkingFolder%\%WorkingFolderName%.FolderContents.txt
- @ECHO Creating contents list in %ListFile% and opening Notepad++
- GOTO cleanup
- REM Move the list file to the proper folder and head to the endgame.
- :cleanup
- RD /S /Q %temp%\folder-list\ 2>nul
- IF EXIST "%ListFile%" GOTO NoteStart
- @ECHO Nothing to do!
- GOTO :eof
- :NoteStart
- Start Notepad++ %ListFile%
- REM You can replace this command with
- REM Start Notepad %ListFile%
- REM or
- REM TYPE %listfile%
- REM Or whatever you want. Remove it entirely! Nothing will break.
- GOTO :eof
- :DeQuote
- for /f "delims=" %%A in ('echo %%%1%%') do set %1=%%~A
- REM Credit to SS64.com for the "quotation strip" function.
- REM I found it here: https://ss64.com/nt/syntax-dequote.html
- Goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement