![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | moving files..... I need a script that will check a given directory for .pdf and .xls files that have exactly the same name. If a pair of .pdf and .xls files with the same name are found, the script should move the .xls file to another directory. Any guidance would be appreciated. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: moving files..... "Doug Howell" <douglasehowell@newsgroup> wrote in message news:a8b0c282-0785-4a2e-8929-b6fe25bbebcf@newsgroup Quote: >I need a script that will check a given directory for .pdf and .xls > files that have exactly the same name. If a pair of .pdf and .xls > files with the same name are found, the script should move the .xls > file to another directory. > > Any guidance would be appreciated. newsgroup. Did you try the suggestion that you received? |
My System Specs![]() |
| | #3 (permalink) |
| | Re: moving files..... Doug Howell schrieb: Quote: > I need a script that will check a given directory for .pdf and .xls > files that have exactly the same name. If a pair of .pdf and .xls > files with the same name are found, the script should move the .xls > file to another directory. > > Any guidance would be appreciated. +---dst \---src F0001.pdf F0001.xls (b) F0002.xls F0003.pdf F0004.txt F0005.pdf F0005.xls (b) F0006.xls F0007.pdf F0008.txt F0009.pdf F0009.xls (b) F0010.xls with 3 .XLSs that have .PDF 'brothers', this code: Dim oFS : Set oFS = CreateObject( "Scripting.FileSystemObject" ) Dim sSDir : sSDir = ".\movebrothers\src" Dim sDDir : sDDir = ".\movebrothers\dst" ' Loop over all files in sSDir Dim oFile For Each oFile In oFS.GetFolder( sSDir ).Files If "XLS" = UCase( oFS.GetExtensionName( oFile.Name ) ) Then ' found .xls Dim sBro : sBro = sSDir & "\" & oFS.GetBaseName( oFile.Path ) & ".pdf" If oFS.FileExists( sBro ) Then ' found brother Dim sDst : sDst = sDDir & "\" & oFile.Name oFile.Move sDst End If End If Next will result in: +---dst | F0001.xls | F0005.xls | F0009.xls | \---src F0001.pdf F0002.xls F0003.pdf F0004.txt F0005.pdf F0006.xls F0007.pdf F0008.txt F0009.pdf F0010.xls |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Moving files | Microsoft Office | |||
| moving files | Vista General | |||
| Moving Files | Vista performance & maintenance | |||
| Moving files | Vista file management | |||
| moving files | General Discussion | |||