excel - 从 Excel 列表中提取文件
问题描述
我在 excel 中有一个文件列表(该列表由 100 个图像文件名组成),以及一个包含 1000 个图像(实际图像)的文件夹,其中 100 个在 excel 列表中。根据 excel 中的列表,我如何将这 100 张图像移动/复制到新文件夹中?
解决方案
您可以运行 powershell 脚本(我假设您使用的是 windows)从单元格中提取数据,然后从一条路径移动到另一条路径。以下脚本应该对您的 xlsx 文件名和路径进行一些修改后对您有用。
$endRow= 100 #this is the last row of image locations
$col = "A"
$newPath = "C:\Users\evolve\Documents\imgFolder\"
$excel = New-Object -Com Excel.Application
$workBook = $excel.Workbooks.Open("C:\Users\evolve\Documents\takeoff.xlsx")
$workSheet = $workBook.sheets.item("sheet1")
#different methods can be used to get the outcome you want.
#cycle through the rows of data
for($i = 1; $i -le $endRow; $i++)
{
$loc = $col + $i
$imgPath = $workSheet.Range($loc).Text
#extract the actual filename
$split = $imgPath.split("\")
$imgName=[string]$split[($split.count-1)]
$newImgLocation = $newPath + $imgName
#move the image to the new folder
Move-Item $imgPath $newImgLocation
}
推荐阅读
- google-play-console - 您的应用容易受到 Intent 重定向的影响
- javascript - 是否有一个事件侦听器可以处理使用 JavaScript 中的 delete 运算符删除对象键的情况?
- json - 如何使用 jmeter 打开和更新 json 文件,然后运行批处理脚本
- javascript - 如何在 documentclient.batchWrite() 中使用复合主键?
- angular-slickgrid - 有没有一种简单的方法可以从按钮而不是右键单击启动内置的 Angular-slickgrid 列选择器菜单
- mysql - 如何复制一行 50 次并在 MySQL 中使用自动增量 id 字段插入到同一个表中?
- docusignapi - Docusign 选项卡的大小不一样,上传可填写的 pdf 字段
- r - 模拟 R 语言“?” shell中的命令(bash/zsh)?
- r - 在data.table中聚合时如何查看多个“by”中逗号分隔字符串背后的逻辑?
- pandas - Pandas covid 数据框:每个县每天获取病例