Home > other >  How to save Folder Names My own Predefined Value in a > .txt file via Batch | CMD
How to save Folder Names My own Predefined Value in a > .txt file via Batch | CMD

Time:09-17

I'm trying to upload a bunch of .7z files to my Server where my customers can get automatic download links. Once I upload the .7z files, I need to copy/paste the last file extension in a .txt editor and parse it with my website's custom URL. It's something like this:


{.7z Files}

001187238.7z

009181905.7z


{Server/Link Folder}

https://website/s1/2291817181/918291918/

https://website/s1/8817530194/114532001/


{Download Links / Finished Process}

https://website/s1/2291817181/918291918/009181905.7z

https://website/s1/8817530194/114532001/001187238.7z


Is there any way where I can run

dir /B %userprofile%\Desktop\folder > --foldernames--.txt

and maybe combine it with a fixed string/link:

https://website/s1/2291817181/918291918/

So, that in the end I get a link the folder name combined, and saved inside the .txt file?

Thank you!

CodePudding user response:

I'm struggling to understand what you want from your description (especially, how to determine, which file should be connected to which folder), but to answer the question itself:

@echo off
(for /f "delims=" %%a in ('dir /B %userprofile%\Desktop\folder\*.7z') do (
  echo https://website/s1/2291817181/918291918/%%a
)) > --foldernames--.txt
  • Related