{"id":26833054,"url":"https://github.com/ermjs/excel-vba-folder-files","last_synced_at":"2026-01-08T12:06:58.928Z","repository":{"id":191142076,"uuid":"684010079","full_name":"ermjs/Excel-VBA-folder-files","owner":"ermjs","description":"Excel-VBA-folder-files","archived":false,"fork":false,"pushed_at":"2023-08-28T09:03:28.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T14:14:22.918Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ermjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-28T09:02:53.000Z","updated_at":"2023-08-28T09:02:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"03b5bce7-9517-4424-8be7-31b2adfe8d8a","html_url":"https://github.com/ermjs/Excel-VBA-folder-files","commit_stats":null,"previous_names":["erman999/excel-vba-folder-files","ermjs/excel-vba-folder-files"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermjs%2FExcel-VBA-folder-files","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermjs%2FExcel-VBA-folder-files/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermjs%2FExcel-VBA-folder-files/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ermjs%2FExcel-VBA-folder-files/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ermjs","download_url":"https://codeload.github.com/ermjs/Excel-VBA-folder-files/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246336973,"owners_count":20761134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-30T15:26:38.035Z","updated_at":"2026-01-08T12:06:58.900Z","avatar_url":"https://github.com/ermjs.png","language":null,"readme":"# Excel-VBA-folder-files\nExcel-VBA-folder-files\n\n```vba\nSub moveFiles()\n\nDim oFSO As Object 'FileSystemObject\nDim oFolder As Object 'Scan target folder\nDim oFile As Object 'Found target file\nDim fileObj As Object 'File object for mod date\nDim fileModDate As String\nDim fileModDateEpoch As Double 'Fake windows epoch\nDim fileDate As Integer 'Strip after decimal and preserve date as integer\nDim shift As String\nDim osPathSeperator As String 'Operation system path seperator\nDim mainFolder As String\nDim newFolder As String\nDim mainFolderPath As String\nDim newFolderPath As String\n\nosPathSeperator = \"\\\" 'Define for windows\nmainFolder = \"Fotolar\"\nnewFolder = \"Yeni\"\nmainFolderPath = ActiveWorkbook.Path \u0026 osPathSeperator \u0026 mainFolder\nnewFolderPath = ActiveWorkbook.Path \u0026 osPathSeperator \u0026 newFolder\n\n'Define active path\n'Debug.Print \"Main Folder Path --\u003e \" \u0026 mainFolderPath\n'Debug.Print \"New Folder Path --\u003e \" \u0026 newFolderPath\n\n\n'Create FileSystemObject\nSet oFSO = CreateObject(\"Scripting.FileSystemObject\")\n\n'Create working folders\nIf Not oFSO.FolderExists(newFolderPath) Then\n  oFSO.CreateFolder newFolderPath\nEnd If\n\nIf Not oFSO.FolderExists(mainFolderPath) Then\n  oFSO.CreateFolder mainFolderPath\nEnd If\n\n'Scan dir\nSet oFolder = oFSO.GetFolder(newFolderPath)\n\n\n'Loop each file\nFor Each oFile In oFolder.Files\n    \n    Set fileObj = oFSO.GetFile(oFile) 'Get file object\n    'fileModDate = fileObj.DateLastModified 'Read mod timestamp as string\n    fileModDateEpoch = CDbl(fileObj.DateLastModified) 'Convert to epoch before converting string\n    \n    'Find shift\n    If fileModDateEpoch \u003e= Int(fileModDateEpoch) + (1 / 24 * 0) And fileModDateEpoch \u003c Int(fileModDateEpoch) + (1 / 24 * 8) Then\n      shift = Format(fileModDateEpoch, \"yyyy-mm-dd\") \u0026 \" 00-08\"\n    ElseIf fileModDateEpoch \u003e= Int(fileModDateEpoch) + (1 / 24 * 8) And fileModDateEpoch \u003c Int(fileModDateEpoch) + (1 / 24 * 16) Then\n      shift = Format(fileModDateEpoch, \"yyyy-mm-dd\") \u0026 \" 08-16\"\n    ElseIf fileModDateEpoch \u003e= Int(fileModDateEpoch) + (1 / 24 * 16) And fileModDateEpoch \u003c Int(fileModDateEpoch) + (1 / 24 * 24) Then\n      shift = Format(fileModDateEpoch, \"yyyy-mm-dd\") \u0026 \" 16-24\"\n    End If\n    \n    ' Show shift\n    'Debug.Print mainFolderPath \u0026 osPathSeperator \u0026 shift\n    \n    'Check if folder exist\n    If Not oFSO.FolderExists(mainFolderPath \u0026 osPathSeperator \u0026 shift) Then\n      'Create folder\n      oFSO.CreateFolder mainFolderPath \u0026 osPathSeperator \u0026 shift\n    End If\n    \n    \n    'Move file to related folder\n    'MoveFile doesnt have overwrite option\n    'oFSO.MoveFile Source:=oFile, Destination:=mainFolderPath \u0026 osPathSeperator \u0026 shift \u0026 osPathSeperator \u0026 oFile.Name\n    \n    'Copy paste alternative\n    oFSO.CopyFile oFile, mainFolderPath \u0026 osPathSeperator \u0026 shift \u0026 osPathSeperator \u0026 oFile.Name, True\n    oFSO.DeleteFile oFile\n        \n    'Debug.Print oFile\n    'Debug.Print oFile.Name\nNext oFile\n\n'Clear memory\nSet oFSO = Nothing\nSet oFolder = Nothing\n\nEnd Sub\n```\n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fermjs%2Fexcel-vba-folder-files","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fermjs%2Fexcel-vba-folder-files","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fermjs%2Fexcel-vba-folder-files/lists"}