如何重命名/移动文件并保留文件名的中间位置?我正在使用通配符查找文件

时间:2019-02-26 17:41:23

标签: linux bash

我正在尝试将文件process_12345678.pdf重命名为process_12345678_0219.pdf

我要添加文件扩展名之前的月份/年份,这就是我一直在尝试的方法。

mv process_*{,_$(date +%m%y)}.pdf

这会将文件名更改为process_*_0219.pdf

中间的数字12345678每次运行该进程时都会更改。我不记得或找不到如何保留进程号。

1 个答案:

答案 0 :(得分:1)

Dim WS_Count, var_int As Integer
Dim PCache As PivotCache
Dim PRange As Range
Dim PTable As PivotTable

'Currently believe I need to create my pivot cache manually

Set PCache = ThisWorkbook.PivotCaches.Create(SourceType:=xlConsolidation, SourceData:=ThisWorkbook.Worksheets(2).Range("A1:D5"))

WS_Count = ThisWorkbook.Worksheets.Count


   For var_int = 2 To WS_Count
        Set PRange = ThisWorkbook.Worksheets(var_int).Range("A1:D5")
        Set PCache = ThisWorkbook.PivotCaches.Add(SourceType:=xlConsolidation, SourceData:=PRange)
    Next var_int

'Basic Error Checks

On Error Resume Next
Set PTable = ThisWorkbook.Worksheets(1).PivotTables("Summary")

On Error GoTo 0

'This is the headache area.  Both halves of the if statement currently fail, but I am only interested in the situation that the PTable = Summary exists
If PTable Is Nothing Then
'    PTable = ThisWorkbook.Worksheets(1).PivotTables.Add(PivotCache:=PCache, TableDestination:=ThisWorkbook.Worksheets(1).Range(2, 7), TableName:="Summary")
     PTable = PCache.CreatePivotTable(TableDestination:=ThisWorkbook.Worksheets(1).Range("G5"), TableName:="Summary")
Else
'When run, I get the aforementioned error.  Most versions of this seem to have users creating a new pivot table, but I would like to update an existing one
PTable.ChangePivotCache PCache
'    PTable = ThisWorkbook.Worksheets(1).PivotTables.Add(PivotCache:=PCache, TableDestination:=ThisWorkbook.Worksheets(1).Range("A5"), TableName:="Summary")
    PTable.RefreshTable
    Set PCache = Nothing
End If
End Sub

请参阅https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html