指向指向当前日期的文件夹的快捷方式.YYYY_MM_DD格式 [英] Shortcut that points to folder named the current date. YYYY_MM_DD Format

查看:57
本文介绍了指向指向当前日期的文件夹的快捷方式.YYYY_MM_DD格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我是日常项目的一部分.每天,我们都会创建一个新文件夹,用于存储当天的所有文件.它根据当前日期命名,并在前面添加一个表示情节"的计数器.格式为WXYZ_YYYY_MM_DD.

So I am part of daily project. Each day, we create a new folder where we store all of our files for that day. It is named according to the current date, with a counter added to the front representing the 'episode'. The format is WXYZ_YYYY_MM_DD.

EX:

0001_2013-05-09

0001_2013-05-09

0002_2013-05-10

0002_2013-05-10

0003_2013-05-13

0003_2013-05-13

0004_2013-05-14

0004_2013-05-14

该文件夹已经被创建,但是我需要做一个快捷方式,该快捷方式将始终将您带到当天的当前"文件夹.

The folders are already being created, but I need to make a shortcut that will always take you to the 'current' folder for the day.

确定了我的选择之后,Powershell似乎将是最简单的.我知道我需要在这里使用调度程序,但是在删除现有快捷方式以创建新快捷方式或编辑现有快捷方式路径值之间会感到困惑.不完全确定如何增加我的剧集并将其附加到日期值.我要在这里追加字符串吗?

After working out my options, it seems like Powershell will be the most straightforward. I know I need to use scheduler here, but am torn between deleting existing shortcuts to create a new one, or editing existing shortcut path values. Not exactly sure how to increment my episode and append it to the date value. Do I want to be appending strings here?

我比Shell更精通C ++和Java.很久没有与他们合作,因此在这里提供的任何帮助都值得赞赏.

I'm much more versed in C++, and Java than shells. Haven't worked with them in a long while so any help here is appreciated.

推荐答案

您可以使用以下内容在Powershell中创建快捷方式.

You can create shortcuts in powershell using the following.

$sh = New-Object -ComObject WScript.Shell
$shortCut = $sh.CreateShortcut("C:\latest_folder.lnk")
$shortCut.TargetPath = "C:\foo\bar.txt"
$shortCut.Save()

您甚至不需要每次都删除旧的.如果只执行相同的代码,它将覆盖旧的快捷方式.

You don't even need to remove the old one each time. If you just execute the same code it will overwrite the old shortcut.

要获取最新文件夹,您只需使用以下行即可.

For grabbing the latest folder you can just use the following line.

$file = Get-ChildItem -Path "c:\Foo" | Sort-Object -Descending LastWriteTime | select -First 1

$ file.FullName将为您提供该文件夹/文件的完整路径.

$file.FullName will then give you the full path to that folder/file.

这篇关于指向指向当前日期的文件夹的快捷方式.YYYY_MM_DD格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆