Jill
04-12-2018, 10:04 PM
Hi forum members.
I'm hoping someone can shed light on what I'm doing wrong.
I have a number of files within a folder. I want to open only the files that have the word "shadow" in their filename. I want to open these files in the photoshop application.
The script works when referencing the exact path with filename, but I can't use the exact path because the filename is variable (however it always contains "shadow"). I left my attempts that failed commented out.
Sub Main()
LayerFiles "C:\Rendermation\Renders"
End Sub
Sub LayerFiles(strFolder)
Dim ObjPhotoshop
Dim fso, folder, files, folderIdx
Dim arrFileType
Dim arrCameraAngle
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(strFolder)
Set files = folder.files
Set ObjPhotoshop = CreateObject("Photoshop.Application")
For Each folderIdx In files
arrFileType = Split(folderIdx.Name, ".")
If IsArray(arrFileType) Then
If arrFileType(UBound(arrFileType)) = "png" Then
ObjPhotoshop.Open "C:\Rendermation\Renders\bluestone_Flair_Channel_Cushion_R_3-4X3-4.3dm_Shadow.png"
' ObjPhotoshop.Open & Chr(34) & strFolder & folderidx.name & Chr(34)
' ObjPhotoshop.Open "& Chr(34) & strFolder & folderIdx.Name & Chr(34) & "
' ObjPhotoshop.Open "C:\Rendermation\Renders" & "*Shadow"
End If
End If
Next
End Sub
Function FileExists(strFile)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFile) Then
FileExists = True
Else
FileExists = False
End If
Set objFSO = Nothing
End Function
Function MkDir(strDirectory)
Dim objFSO
Dim objFolder
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strDirectory)
Set objFolder = Nothing
Set objFSO = Nothing
End Function
Function FolderExists(strFolder)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strFolder) Then
FolderExists = True
Else
FolderExists = False
End If
Set objFSO = Nothing
End Function
I'm hoping someone can shed light on what I'm doing wrong.
I have a number of files within a folder. I want to open only the files that have the word "shadow" in their filename. I want to open these files in the photoshop application.
The script works when referencing the exact path with filename, but I can't use the exact path because the filename is variable (however it always contains "shadow"). I left my attempts that failed commented out.
Sub Main()
LayerFiles "C:\Rendermation\Renders"
End Sub
Sub LayerFiles(strFolder)
Dim ObjPhotoshop
Dim fso, folder, files, folderIdx
Dim arrFileType
Dim arrCameraAngle
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(strFolder)
Set files = folder.files
Set ObjPhotoshop = CreateObject("Photoshop.Application")
For Each folderIdx In files
arrFileType = Split(folderIdx.Name, ".")
If IsArray(arrFileType) Then
If arrFileType(UBound(arrFileType)) = "png" Then
ObjPhotoshop.Open "C:\Rendermation\Renders\bluestone_Flair_Channel_Cushion_R_3-4X3-4.3dm_Shadow.png"
' ObjPhotoshop.Open & Chr(34) & strFolder & folderidx.name & Chr(34)
' ObjPhotoshop.Open "& Chr(34) & strFolder & folderIdx.Name & Chr(34) & "
' ObjPhotoshop.Open "C:\Rendermation\Renders" & "*Shadow"
End If
End If
Next
End Sub
Function FileExists(strFile)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFile) Then
FileExists = True
Else
FileExists = False
End If
Set objFSO = Nothing
End Function
Function MkDir(strDirectory)
Dim objFSO
Dim objFolder
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strDirectory)
Set objFolder = Nothing
Set objFSO = Nothing
End Function
Function FolderExists(strFolder)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strFolder) Then
FolderExists = True
Else
FolderExists = False
End If
Set objFSO = Nothing
End Function