Write batch to find files and make shortcuts

Microsoft Windows 7 ultimate 64-bit
August 11, 2010 at 22:03:37
Specs: Windows 7
Hi, I'm trying to write a batch file that will search g:\downloads f:\tv and g:\tv for files created in the last 4 days then create short cuts for these files in d:\other\. I also need it to erase all files in d:\other so it starts new every time it's run. Can anyone help me?

See More: Write batch to find files and make shortcuts

Report •


#1
August 12, 2010 at 07:50:20
Before we do anything, I simply must know who is this "Erich," and why do you "hat" him?

Report •

#2
August 12, 2010 at 16:09:56
It is a reference to "The Opie and Anthony Show" referencing a line from the movie "The Fly" where someone yells "I HATE RICH ****s"

Report •

#3
August 14, 2010 at 05:23:47
Well alright then.
Const outDir = "d:\other"
scanDirs = Array("g:\downloads", "f:\tv", "g:\tv")
Set fso = CreateObject("Scripting.FileSystemObject")
Set shell = CreateObject("WScript.Shell")

For Each d In scanDirs
  For Each f In fso.GetFolder(d).Files
    If f.DateCreated > Now - 4 Then
      With shell.CreateShortcut(outDir & "\" & f.Name & ".lnk")
        .TargetPath = f
        .Save
      End With
    End If
  Next 'f
Next 'd


Report •

Related Solutions

#4
August 14, 2010 at 10:13:57
Thanks for your help. Can I copy this to notepad and save it as a batch file or does it need to be compiled?

Thanks again


Report •

#5
August 15, 2010 at 03:34:06
Sorry; should probably have mentioned it was a VBScript. Open Notepad and save it as a .VBS file.

Report •

#6
August 15, 2010 at 09:53:46
Thanks alot. Is there anyway I can edit it to only search for media files like .avi, .mkv, .mp4, etc?

Report •

#7
August 16, 2010 at 06:47:01
Yes, but I hate this, "let's tack on feature X," back and forth that's so common with these threads. Tell me EVERYTHING you want it to do, and someone (me) will see about doing it.

Report •


Ask Question