How to reformat all daily journal TITLE?

So I already have daily notes from 2022. It has always been YYYY-MM-DD. But Now I want reformat ALL existing daily notes into MMM Do, YYYY.

Is there a way to do that?

Things I have tried

I checked the Linter plugin. Doesn’t seem to fit my need.

You can use ChatGPT Plus ($20 / month) for this. It can bulk rename files according to your instructions. It can also generate shell scripts for this kind of problems.

From ChatGPT:

You can use the following PowerShell script to rename files that are named in the YYYY-MM-DD format to the MMM dd, YYYY format.

Here’s the script:

# Get all files in the directory (you can specify a path or use the current directory)
$files = Get-ChildItem -Path "C:\Path\To\Your\Files"

foreach ($file in $files) {
    # Extract the base file name without extension
    $baseName = [System.IO.Path]::GetFileNameWithoutExtension($file.Name)
    
    # Match the date pattern YYYY-MM-DD using regex
    if ($baseName -match '^\d{4}-\d{2}-\d{2}$') {
        # Convert the date from YYYY-MM-DD to DateTime object
        $date = [DateTime]::ParseExact($baseName, 'yyyy-MM-dd', $null)
        
        # Format the date in MMM dd, yyyy format
        $newName = $date.ToString("MMM dd, yyyy") + $file.Extension
        
        # Rename the file
        $newPath = Join-Path $file.DirectoryName $newName
        Rename-Item -Path $file.FullName -NewName $newPath
        
        Write-Host "Renamed '$($file.Name)' to '$newName'"
    }
}

How the script works:

  1. It gets all files in the specified directory.
  2. It checks if the file name matches the YYYY-MM-DD pattern using regex (^\d{4}-\d{2}-\d{2}$).
  3. It converts the date part of the filename to a DateTime object.
  4. It then formats the date to MMM dd, yyyy (e.g., Jan 01, 2024).
  5. The script renames each file with the new date format, while preserving its extension.

How to use:

  1. Replace "C:\Path\To\Your\Files" with the path to your folder containing the files.
  2. Run the script in PowerShell.

This should rename all the files with the date in the YYYY-MM-DD format to the desired MMM dd, yyyy format.

1 Like

Thank you so much. I 'm not a subscriber, and will explore other solution. If can’t find any other solution. Will try ChatGPT.
Thanks!

Just a few thoughts here:

  • YYYY-MM-DD as UUID – while rudimentary – is perfect for titles. I wouldn’t want to change them.
    • What people usually do is use Dataview queries and reformat date structure for results output as one would for aliases (but aliases currently cannot function as titles in the Obsidian UI).
  • The script above doesn’t do content search for possible backlinks and update those as well. Hence this script as it is would break backlinks.
    • I like to get Python scripts written for cross-platform usage, where I specify vault paths for Windows and Linux. I don’t think I have more than one Powershell script myself.
    • When using scripts, try them out on test vaults first.

So the thing is I have dates in other format (imported from other noting app). These dates are linked to actually journal date, but the format is different from my obsidian date format.
So, I was thinking to change the obsidian journal date format to MMM Do, YYYY, allowing the links to be established (probably need to reindex) and then change it back to YYYY_MM_DD. I think perhaps this way I could change all the date format and links both in title and in content back to original date format. So that I don’t have to re establish all date links in my other notes.

any thought to complete that ?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.