You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

anjanesh's avatar
anjanesh
Helpful | Level 6
5 years ago

.dropbox-ignore to prevent folders being uploaded to DropBox like git's .gitignore

Just like we have .gitignore for preventing files / folders to be uploaded to github, it would be nice to have the same for DropBox.

I have a workspace folder with tons of node_modules folders.

I want to upload the workspace folder to my DropBox but want to skip the node_modules folders.

Is there a way to achive this by making some .dropbox-ignore entry in my workspace's folders ?

That would be really helpful. Thanks.

  • andresharpe's avatar
    andresharpe
    New member | Level 2

    This might be useful for others on Windows and Powershell with the git command line tool installed.

     

    The script finds all .gitignore files in current folder and subfolder and sets the ignored files and folders to not upload to Dropbox.

     

    Get-ChildItem -Recurse | `
        Where-Object { $_.Name -eq '.gitignore' } | `
        ForEach-Object { `
            Write-Host $_.DirectoryName; `
            Push-Location $_.DirectoryName; `
            git status --ignored --short | `
                Where-Object { $_.StartsWith('!! ') } | `
                ForEach-Object { `
                    $ignore = $_.Split(' ')[1].Trim('/'); `
                    Write-Host $ignore; `
                    Set-Content -Path $ignore -Stream com.dropbox.ignored -Value 1 `
                }; `
            Pop-Location }

    You can paste this into say `dropbox-sync-ignore.ps1` and store in your PATH and run it whenever you start or update a project in git.

    • anjanesh's avatar
      anjanesh
      Helpful | Level 6

      DropBox should come up with an update that provides this out of the box. Right now running this

      xattr -w com.dropbox.ignored 1 /Users/yourname/Dropbox/workspace/react-project/node_modules

      for every node project manually is a pain.

      • denysp's avatar
        denysp
        Explorer | Level 4

        Try this one:
        `xattr -w com.dropbox.ignored 1 /Users/yourname/Dropbox/**/node_modules`
        It should mark recursively all node module folders in your Dropbox.

  • Bloodreaver's avatar
    Bloodreaver
    New member | Level 2

    Hello!

     

    This will not be an ideal solution for everyone but I find it useful. I am using windows 11 and this works well for me, I basically just use it on my node.js projects' node_modules directory to stop all that junk from being synced.

     

    The end result, you can see the node_modules folder is now being ignored:

     

    You will need to modify the registry and store some powershell script files somewhere on your system where they won't be moved or deleted etc. You could even store them in your dropbox if you wanted! If you are not comfortable doing this then you will have to find a different solution.

     

    There are 4 files to make, 1 registry file and 1 powershell script file for adding the ignore and another 1 of each to remove the ignore, if you wish.

    If you are comfortable using regedit, you could forego creating the registry files in favour of manually creating the keys and values, but I'll leave that up to you.

     

    • You may change the key names in the registry to whatever you wish, I just used dropbox_ignore and dropbox_stop_ignoring for the sake of simplicity, you may also change the text displayed in the context menu if you like.
    • The ampersand (&) is used to define a mnenomic key which can be used to select the command quickly with the keyboard, in this case I have elected to use "d" for both but you may change it, just move the ampersand to just before whichever letter you wish you use as the mnenomic.
    • I suggest leaving the path to powershell.exe as is, I have powershell 7 installed and I did try to direct it to that instead initially but it refused to work, whereas just using the 1.0 powershell seems to work fine, I'm not sure why but if it ain't broke don't fix it, I suppose.

    Yes, all those backslash characters (\) are necessary, and if you change the path to your powershell scripts, be sure to put two backslashes to represent a directory separator as it must be "escaped" (the backslash character is used to tell the system that the character following it is a literal character and not an escape character, so we have to use two there, and four in the actual powershell path).

     

    To use these, simply create the files as shown below and then run the .reg files to insert the values into the registry, or create the keys and values manually if you prefer. Once you've done that, the commands should show up in your explorer shell context menus when you right click upon a folder. In Windows 11, you will likely have to choose the "Show More Options" menu item at the bottom of the context menu in order to see the new commands.

     

    Registry File: dropbox ignore command.reg

     

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\Directory\shell\dropbox_ignore]
    @="&Dropbox Ignore"
    
    [HKEY_CLASSES_ROOT\Directory\shell\dropbox_ignore\command]
    @="C:\\\\Windows\\\\system32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe -File \"C:\\powershell scripts\\dropbox\\dropboxignore.ps1\" \"%L\""

     

     

    Powershell Script: dropboxignore.ps1

     

    $path = $args[0]
    
    Set-Content -Path $path -Stream com.dropbox.ignored -Value 1

     

     

    Registry File: dropbox stop ignore command.reg

     

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\Directory\shell\dropbox_stop_ignoring]
    @="&Dropbox Stop Ignoring"
    
    [HKEY_CLASSES_ROOT\Directory\shell\dropbox_stop_ignoring\command]
    @="C:\\\\Windows\\\\system32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe -File \"C:\\powershell scripts\\dropbox\\dropboxignore-remove.ps1\" \"%L\""

     

     

    Powershell Script: dropboxignore-remove.ps1

     

    $path = $args[0]
    
    Clear-Content -Path $path -Stream com.dropbox.ignored

     

     

    I hope this helps some people, until Dropbox finally just adds their own command to the context menu and/or support for ignore files.

    Happy syncing!

    • Darcey's avatar
      Darcey
      Explorer | Level 4

      What a solution, at least it can be done with a lot of work and command line BS...

      Pathetic...

       

      If you actually implemented .gitignore capabilities, you would actually get me to move away from GDrive to your services, but as is... Not a chance...

      • anjanesh's avatar
        anjanesh
        Helpful | Level 6

        Yes, running that command is a tedious task. DropBox should implement a .drop-ignore setting setup like .gitignore.

  • Steve A.13's avatar
    Steve A.13
    Helpful | Level 7
    Agree we need a way to ignore files and folders. The power shell method is too complex. And I’d like wildcards, so I could ignore *.tmp, *.bak, *.obj, etc files in all folders.
    • Steve A.13's avatar
      Steve A.13
      Helpful | Level 7

      Are there "Dropbox ignore settings"? Only on Linux?

       

      Synching Dropbox ignore settings to .gitignore would be nice, but I'd be thrilled to have any way to have Dropbox ignore specify files or file types.

      • coder0xff's avatar
        coder0xff
        Explorer | Level 3

        The settings I'm referring to are the com.dropbox.ignored extended attribute that can be set on a per-file and per-directory basis. They can be set manually using the attr command. My script automates setting or clearing the attribute based on .gitignore. See https://help.dropbox.com/sync/ignored-files

About Create, upload, and share

Find help to solve issues with creating, uploading, and sharing files and folders in Dropbox. Get support and advice from the Dropbox Community.

Need more support

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!