Hey fellow developers! π Today we're diving into one of Uniface's handy ProcScript commands that makes directory management a breeze: dirrename. Whether you're organizing your project structure or managing dynamic file operations, this command is your friend! β¨
What is dirrename? π€
The dirrename
statement is Uniface's built-in solution for renaming directories programmatically. It's clean, simple, and handles all the platform-specific details for you.
Basic Syntax π
dirrename DirPath, NewDirName
Quick Example π
dirrename "data/exports", "saved"
That's it! Your "exports" directory inside "data" is now called "saved". Pretty straightforward, right? π
Parameters Breakdown π
Parameter | Data Type | Description |
---|---|---|
DirPath | String | Directory name with optional path. Can even be in a zip archive! π¦ |
NewDirName | String | New directory name. Keep it simple - no path separators at the end! β οΈ |
Return Values & Error Handling π‘οΈ
Always check your $procerror
value:
- 0: Success! π
- -13: OS command error (use
/pri=64
for details) β
Pro Tips & Best Practices π‘
Path Separators
Uniface is smart about separators! You can use:
- Forward slash:
/
- Backward slash:
\
- Bracket notation:
[a.b]
Different Ways to Rename
// Standard approach
dirrename "drinks/coffee/", "tea"
// Bracket notation (my personal favorite! π)
dirrename "[drinks.coffee]", "tea"
// Using $RES (resources path)
dirrename "$RES:drinks/coffee", "tea"
When Things Go Wrong π¨
The operation will fail if:
Source Directory Issues:
- Directory doesn't exist π«
- Not actually a directory
- Directory is not empty
- Directory is locked/in use π
- Insufficient permissions
Target Name Issues:
- Name already exists π
- Invalid syntax
- Trying to use $RES as target
Special Considerations π―
iSeries Users
Library renaming has special rules - libraries must not be in use or on someone else's library list. Always be prepared for negative return values! π
Path Limitations
Keep your paths under 255 bytes total length. Modern systems shouldn't have issues, but it's good to know! π
Real-World Example π
// Let's organize our backup directories
if ($procerror = 0)
dirrename "backup/temp", "backup_" + $date
if ($procerror != 0)
message "Failed to rename backup directory!"
endif
endif
Wrapping Up π
The dirrename
command is a powerful yet simple tool in your Uniface toolkit. It handles cross-platform compatibility gracefully and integrates seamlessly with Uniface's file system abstractions.
Remember to always check your error codes, and don't forget about those path length limitations! Happy coding! π
Found this helpful? Drop a π and let me know in the comments! Got questions about other Uniface commands? I'd love to help!
π Based on Uniface Documentation 10.4 | Created with AI assistance
Top comments (0)