找回密码
 注册

QQ登录

只需一步,快速开始

查看: 193|回复: 0

Organise your digital photos into subdirectory using Powershell

[复制链接]
发表于 2013-5-17 12:28:18 | 显示全部楼层 |阅读模式
  1. # ==============================================================================================
  2. #
  3. # Microsoft PowerShell Source File -- Created with SAPIEN Technologies PrimalScript 4.1
  4. #
  5. #
  6. # COMMENT: Helps you organise your digital photos into subdirectory, based on the Exif data
  7. # found inside the picture. Based on the date picture taken property the pictures will be organized into
  8. # c:\Test\photoes\DD-MM-YYYY
  9. # ==============================================================================================

  10. [reflection.assembly]::loadfile( "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll")

  11. $Files = Get-ChildItem -recurse -filter *.jpg
  12. foreach ($file in $Files)
  13. {
  14.   $foo=New-Object -TypeName system.drawing.bitmap -ArgumentList $file.fullname

  15. #each character represents an ascii code number 0-10 is date
  16. #10th character is space separator between date and time
  17. #48 = 0 49 = 1 50 = 2 51 = 3 52 = 4 53 = 5 54 = 6 55 = 7 56 = 8 57 = 9 58 = :
  18. #date is in YYYY/MM/DD format
  19.   $date = $foo.GetPropertyItem(36867).value[0..9]
  20.   $arYear = [Char]$date[0],[Char]$date[1],[Char]$date[2],[Char]$date[3]
  21.   $arMonth = [Char]$date[5],[Char]$date
  22.   $arDay = [Char]$date,[Char]$date[9]
  23.   $strYear = [String]::Join("",$arYear)
  24.   $strMonth = [String]::Join("",$arMonth)
  25.   $strDay = [String]::Join("",$arDay)
  26.   $DateTaken = $strDay + "-" + $strMonth + "-" + $strYear
  27.   $TargetPath = "c:\Test\photoes" + $strYear + "" + $DateTaken
  28. If (Test-Path $TargetPath)
  29.   {
  30.     xcopy /Y/Q $file.FullName $TargetPath
  31.   }
  32.   Else
  33.    {
  34.     New-Item $TargetPath -Type Directory
  35.     xcopy /Y/Q $file.FullName $TargetPath
  36.    }
  37. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|BC Morning Website ( Best Deal Inc. 001 )

GMT-8, 2026-6-11 03:05 , Processed in 0.012753 second(s), 16 queries .

Supported by Weloment Group X3.5

© 2008-2026 Best Deal Online

快速回复 返回顶部 返回列表