rename-files-date-prefix
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "rename-files-date-prefix" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-8f8c1c368d7c54de0561766ca535ebe854a413b6446eb8ab22108350034dd1ae. Verify the upstream source and version against https://github.com/pnp/sharepoint-skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Rename all files in a SharePoint document library (including subfolders) by adding the creation date as a yyMMdd prefix to filenames (for example: 251203-StatusReport.pdf). Provide a preview before committing changes. Used when users request adding a date prefix to filenames.
Introduction source: third_party · pnp · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Renames all files in a SharePoint document library (including subfolders) to prefix them with their created date in yyMMdd format (e.g., 251203-Status Report.pdf). Offers a preview before committing changes. Use when the user asks to prefix filenames with dates or add date prefixes to files.
- Limits and differences
- Never rename without showing the preview first. Never rename folders. Never double-prefix files. Never append numeric suffixes to resolve name collisions — mark as `Skipped (name collision)` instead. Always process errors gracefully — one failure should not stop the entire batch. Safe to re-run; the `^\d{6}-` skip check protects already-renamed files (see **Resuming after a mid-batch failure**).
- Testing
- Not tested
Browse files
Frontmatter
name: "rename-files-date-prefix"
description: "Renames all files in a SharePoint document library (including subfolders) to prefix them with their created date in yyMMdd format (e.g., 251203-Status Report.pdf). Offers a preview before committing changes. Use when the user asks to prefix filenames with dates or add date prefixes to files."Rename Files with Date Prefix
Rename all files in a SharePoint document library to prefix them with their created date in yyMMdd format (e.g., 251203-Status Report.pdf).
Steps
1. Identify the Target Library
- Use the current document library if the user doesn't specify one.
- Call
get_current_list_or_libraryto get the library ID.
2. Get the Library Schema
- Call
get_list_schemato confirm the library hasCreatedandFileLeafReffields and to understand the structure.
3. Retrieve All Files (Including Subfolders)
- Call
get_list_item_metadatawithfetchAll: trueto retrieve all items. - Use a CAML query that filters to files only (
FSObjType= 0):<Query><Where><Eq><FieldRef Name='FSObjType'/><Value Type='Integer'>0</Value></Eq></Where><OrderBy><FieldRef Name='FileLeafRef' Ascending='TRUE'/></OrderBy></Query>
4. Build the Preview
For each file returned:
- Extract the
Createddate and format it asyyMMdd(2-digit year, 2-digit month, 2-digit day). - Get the current filename from
FileLeafRef. - Determine the folder path from
FileRef(strip the filename to get the folder). - Skip check: If the filename already matches the pattern
^\d{6}-(six digits followed by a hyphen), mark it as skipped with reason "Already has date prefix". - Build the new filename:
yyMMdd-OriginalFilename.
5. Show the Preview Table
Always show the preview before making any changes. Present a markdown table:
| # | Current Name | New Name | Folder | Status |
|---|---|---|---|---|
| 1 | Status Report.pdf | 251203-Status Report.pdf | /sites/Team/Docs | Will rename |
| 2 | 251203-Budget.xlsx | 251203-Budget.xlsx | /sites/Team/Docs/Finance | Skipped (already prefixed) |
Include a summary:
- Total files found: X
- To be renamed: Y
- Skipped: Z
Then ask: "Ready to rename Y files? Confirm to proceed."
6. Rename on Confirmation
Once the user confirms:
- For each file to be renamed, call
update_list_itemswith:itemId: the file's list item IDfieldInternalNames:["FileLeafRef"]newValues:["yyMMdd-OriginalFilename"]
- Process files one at a time to handle errors gracefully.
- If a rename fails, log the error and continue with the remaining files.
7. Report Results
After processing, show a summary:
- Successfully renamed: X files
- Skipped (already prefixed): Y files
- Errors: Z files (list the filenames and error details)
Date Formatting Rules
- Use the file's
Createddate (not Modified). - Format:
yyMMdd— 2-digit year, 2-digit month (zero-padded), 2-digit day (zero-padded). - Example: December 3, 2025 →
251203 - Example: January 15, 2024 →
240115 - Time zone: SharePoint returns
Createdin UTC. Format the prefix from the site's regional time zone, not raw UTC, so a file uploaded at 23:30 local time keeps its local-day date. If the site time zone cannot be determined, fall back to UTC and tell the user once in the preview header ("Dates are formatted in UTC — set the site regional settings to use local time.").
Edge Cases
- Already prefixed files: Skip any file whose name starts with 6 digits followed by a hyphen (
^\d{6}-). - Folders: Never rename folders — only process items where
FSObjType= 0. - Subfolders: Process files in all subfolders recursively (use
fetchAll: true). - Duplicate names after prefixing: If the proposed
yyMMdd-Namealready exists in the same folder, do not rename and do not overwrite. Mark the file asSkipped (name collision)in the preview / results with the conflicting target name shown. Never append numeric suffixes (-1,-2) to disambiguate — the user must resolve the conflict manually. The other files in the batch still rename. - Special characters: Preserve the original filename exactly as-is after the prefix.
- Empty libraries: If no files match the CAML query, tell the user the library has no files to rename and stop — do not show an empty preview table.
Resuming after a mid-batch failure
Long runs can be interrupted — throttling, network drop, the user closing the chat. The skill must be safe to re-run from scratch without any extra bookkeeping:
- The
^\d{6}-skip check automatically excludes every file that was successfully renamed in the previous run. Re-running picks up exactly where the failure stopped. - If a file failed mid-rename (rare — SharePoint renames are atomic), it will still match the original name and be processed again in the next run.
- Do not keep an external "already processed" list, lock file, or marker column. The filename itself is the source of truth.
- After a partial run, the Step 7 results report must clearly distinguish Renamed, Skipped (already prefixed), Skipped (name collision), and Errors so the user can decide whether to re-run.
Example
User: "Prefix all files in this library with their created date"
Agent response (preview):
| # | Current Name | New Name | Folder | Status |
|---|---|---|---|---|
| 1 | Quarterly Review.docx | 250915-Quarterly Review.docx | /sites/Team/Reports | Will rename |
| 2 | 241101-Notes.pdf | 241101-Notes.pdf | /sites/Team/Reports | Skipped (already prefixed) |
| 3 | Budget.xlsx | 250301-Budget.xlsx | /sites/Team/Finance | Will rename |
Total files: 3 | To rename: 2 | Skipped: 1
Ready to rename 2 files? Confirm to proceed.
Constraints
- Never rename without showing the preview first.
- Never rename folders.
- Never double-prefix files.
- Never append numeric suffixes to resolve name collisions — mark as
Skipped (name collision)instead. - Always process errors gracefully — one failure should not stop the entire batch. Safe to re-run; the
^\d{6}-skip check protects already-renamed files (see Resuming after a mid-batch failure).
Current listing version
0.0.1
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 SharePoint 文件批量添加日期前缀功能,解决企业办公中文件管理的实际需求
- 支持子文件夹递归处理,覆盖完整文档库场景
Highlights
- 触发描述清晰明确,覆盖用户要求添加日期前缀的典型场景
Highlights
- 文档结构完整,包含详细步骤、边界情况处理、约束说明和端到端示例
- frontmatter 完整,单文件结构清晰易读
Highlights
- 工具调用合理,参数正确,覆盖主要异常场景
- 提供预览确认机制,支持安全重跑,错误处理完善
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.