Symbolically link new files?
Moderator: DosItHelp
Symbolically link new files?
I want to write a batch file that will search my hard drive for new media files, and create symbolic links for these files in a new directory. How can I do this?
Re: Symbolically link new files?
ihaterich wrote:I want to write a batch file that will search my hard drive for new media files,
What means "new" in your case?
ihaterich wrote:and create symbolic links for these files in a new directory. How can I do this?
You can't create links using batch, sorry.
Regards
aGerman
Re: Symbolically link new files?
Thanks for the reply. I've read mklink could be used to create symbolic links. Is this not correct?
I would define new as being files added in the last 12 hours. Thanks
I would define new as being files added in the last 12 hours. Thanks
Re: Symbolically link new files?
Hmm, I could try to make a chimera of batch and VBScript.
What file extensions would you look for?
In which directory should all the links be placed?
You should think about that searching over the entire hard drive will take a lot of time. Maybe you can restrict it some more.
Regards
aGerman
What file extensions would you look for?
In which directory should all the links be placed?
You should think about that searching over the entire hard drive will take a lot of time. Maybe you can restrict it some more.
Regards
aGerman
Re: Symbolically link new files?
Hi, I would only be looking for extensions .avi .mpg .mp4 .mov .wmv. and .mov
The link folder would be D:\Other\New
I would only need it to search G:\Downloads
thanks again
The link folder would be D:\Other\New
I would only need it to search G:\Downloads
thanks again
Re: Symbolically link new files?
OK. It's almost 1:00 am in Germany, so I have to sleep some hours. I don't forget to write a code for you, but sorry -- not now
Regards
aGerman
Regards
aGerman
Re: Symbolically link new files?
Here it comes:
If something isn't clear, come back with your issues.
Regards
aGerman
Code: Select all
@echo off &setlocal
:: source folder, without final back slash
set "sourceRoot=G:\Downloads"
:: destination folder, without final back slash
set "destFolder=D:\Other\New"
:: search extensions, space separated
set "extensions=*.avi *.mpg *.mp4 *.mov *.wmv"
(
echo\sFileName = WScript.Arguments^(0^) : sFolderName = WScript.Arguments^(1^)
echo\Set oFile = WScript.CreateObject^("Scripting.FileSystemObject"^).GetFile^(sFileName^)
echo\If DateAdd^("h", -12, Now^) ^<= oFile.DateCreated Then
echo\ set oSc = WScript.CreateObject^("WScript.Shell"^).CreateShortcut^("%destFolder%\" ^& oFile.Name ^& ".lnk"^)
echo\ oSc.Description = sFileName
echo\ oSc.TargetPath = sFileName
echo\ oSc.WindowStyle = 1
echo\ oSc.WorkingDirectory = sFolderName
echo\ oSc.Save
echo\End If
)>"%temp%\tmp.vbs"
md "%destFolder%" 2>nul
pushd "%sourceRoot%" ||goto :eof
for /r %%a in (%extensions%) do call "%temp%\tmp.vbs" "%%~a" "%%~dpa"
popd
del "%temp%\tmp.vbs"
pause
If something isn't clear, come back with your issues.
Regards
aGerman
Re: Symbolically link new files?
Thanks so much for your help