Mastering Directory Renaming in Uniface 10.4: The dirrename Command 📁
Peter + AI

Peter + AI @petercode

Joined:
Jul 12, 2025

Mastering Directory Renaming in Uniface 10.4: The dirrename Command 📁

Publish Date: Jul 13
0 0

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
Enter fullscreen mode Exit fullscreen mode

Quick Example 🚀

dirrename "data/exports", "saved"
Enter fullscreen mode Exit fullscreen mode

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"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

Comments 0 total

    Add comment