Deleting files with “too long filenames” in Windows

If you’re using Microsoft Windows and happen to have a file that has a very long filename, more than 260 characters to be percise, you’re living in a hell… Nothing can be done with it! Unless you use a great little tool of course, Robocopy!robocopy

Robocopy is an old product that comes with Windows since Vista (i think?) an can be accessed via Powershell. The thing with Robocopy is that it’s main purpuse is to copy files in one way or another. It has a feature for Mirroring one folder to another. With that said, what happens when you mirror an empty folder with a folder containing files with names too long? You get two empty folders! :) Life’s good!

The basic command for doing this is:
robocopy.exe c:\My\Empty\Folder c:\Folder\With\Long\Names /MIR

What I used this for was cleaning up the INetCache folder that had gone wild and crazy and gave the users alot of problem.
The script I used to clean this folder was:
Get-ChildItem X:\Profilefolder | foreach {robocopy X:\Empty (“X:\Profilefolder\” + “$_” + “\AppData\Local\Microsoft\Windows\INetCache”) /MIR}

This just lists all entries in X:\Profilefolder and handles each entry with a robocopy command that is mirroring the empty folder with the INetCache folder.



LibreOffice 4 Default User Config

LibreOfficeLibreOffice is a great Office suite to use, and is getting more potent as a replacement for Microsoft Office. 

Using it in an enterprise is fairly simple if you’re happy with the predefined config and let your users do all the settings by themselfs. There is, however, a couple of ways to change the predefined settings.

In the program directory (c:\Program Files(x86)\LibreOffice is default) you have the config files located in share\registry with the file extension .xcd. These contain information about what file extension is the default for each program. For example LibreOffice Writer uses writer.xcd.

To change the default file extension for Writer:

1. Open writer.xcd in Notepad

2. Click on Edit / Replace all

3. Search for <prop oor:name=”ooSetupFactoryDefaultFilter”><value>writer8</value> and replace it with <prop oor:name=”ooSetupFactoryDefaultFilter”><value>MS Word 97</value>

4. Save and you’re done!

Check the reference at the bottom for a couple of more examples…

If you already deployed LibreOffice to your users and need to force these new settings to them you need to delete a file in the users profile. The file is called registrymodifications.xcu and contains all settings the user has changed. So the solution is to simply delete this file, and the easiest way to do that for all users is a GPO to automate the process at logon.

So what you need to do is:

1. Open GPMC and create a new GPO or edit an existing one

2. Navigate to User Configuration\Preferences\Windows Settings\Files

3. Add a new file

4. In Actions select Delete

5. In the Target point out the file, %AppDataDir%\Roaming\LibreOffice\4\user\registrymodifications.xcu

6. Change tab to Common, and select Run in logged-on user’s security context (user policy option)

7. Click OK and your Done!

Now all users will have their own configurations erased at logon and your default config will apply. But they’re still allowed to change settings during their active session, so this method doesn’t lock down anything.