PhotopilotPhotopilot
SMB Sync

SMB Sync: from network drive to Photopilot

A small program that watches an SMB/Samba share (such as a StyleShoots machine) and automatically uploads photo folders as shoots and packshots.

  • Shoots

    Folders named S-<set number> (e.g. S-1234) are uploaded as a shoot for that set.

  • Packshots

    Every other folder is considered an item: a scanned EAN/barcode or a public item number. Photos with back, side, or label in the filename are linked as that view — or via your own pattern, see below.

  • Flat mode

    For StyleShoots setups that drop every file loose into the folder: set FLAT_PACKSHOT=true. Loose photos are grouped by article identifier (the part before the first underscore) and synced as packshots.

  • Flat mode

    For StyleShoots setups that drop every file loose into the folder: set FLAT_PACKSHOT=true. Loose photos are grouped by article identifier (the part before the first underscore) and synced as packshots.

  • Safe

    A folder is only synchronized if nothing has changed for 10 minutes. Unknown items are skipped and retried later. For packshots, we only remove the files that have actually been uploaded — the folder and the rest remain.

Installation on Windows Server

  1. Download and unpack

    Download windows-amd64.exe.gz above, unpack it and place smbsync.exe in its own folder, for example C:\Photopilot\smbsync\.

  2. Create a .env file in the same folder
    CUSTOMER=Bedrijfsnaam
    SMB_IP=192.168.1.10
    SMB_USERNAME=styleshootssharing
    SMB_PASSWORD=wachtwoord
    SMB_MOUNT=StyleshootsDrive
    START_DIR=sync
    API_TOKEN=jouw-api-token
    API_URL=https://app.photopilot.ai/api
    LOG_LEVEL=info
    TZ=Europe/Amsterdam
    
    # Optioneel: StyleShoots-modus waarbij alle bestanden los in START_DIR staan
    # (geen submap per artikel). Losse foto's worden gegroepeerd op artikel-
    # identifier (het deel voor de eerste underscore) en als packshots gesynct.
    FLAT_PACKSHOT=false
  3. Point it to your Samba/SMB share

    SMB_IP is the IP address of the machine with the share (e.g., the StyleShoots or your NAS). SMB_MOUNT is the name of the share itself and START_DIR the folder within the share that is synchronized. The account needs read and write permissions: uploaded files are removed from the share after upload.

  4. Start automatically with Windows

    Open Task Scheduler, create a task that starts smbsync.exe when the computer boots and set 'Start in' to the folder containing the .env. Choose 'Run whether user is logged on or not'.

  5. Check

    Create a test folder with an EAN code as the name on the share, put a photo in it, and wait ±10 minutes. The photo will appear with the item in Photopilot and disappear from the share. The folder itself remains, containing a status.json as proof that it has been processed — photos we haven't uploaded also remain. Errors are automatically reported to us via Sentry.

Recognize front, back, and side

By default, SMB Sync looks for the words back, side, and label in the filename; all other photos become their own packshot with that photo as the front. Not every studio names the view in the name. StyleShoots, for example, numbers per item: <EAN>_PNG_1 is the front, _PNG_2 the back, and _PNG_3 the optional side. Then specify the pattern yourself in your .env:

FRONT_IDENTIFIER=_PNG_1$
BACK_IDENTIFIER=_PNG_2$
SIDE_IDENTIFIER=_PNG_3$
  • FRONT_IDENTIFIER Front Default: the first photo that doesn't belong to any other view.
  • BACK_IDENTIFIER Back Default: back in the filename.
  • SIDE_IDENTIFIER Side Default: side in the filename.
  • LABEL_IDENTIFIER Label (care instructions) Default: label in the filename.

With this setting, 8712345678906_PNG_1, _PNG_2, and _PNG_3 come in together as one packshot for item 8712345678906 — not as three separate photos. Is the side missing? Then that view simply remains empty.

Each pattern is case-insensitive and is tested on the filename without extension, so PNG_1 works just as well as _PNG_1$ (the $ sign means: at the end of the name). Once you set FRONT_IDENTIFIER, only photos matching one of these patterns will be uploaded — other files in the folder remain untouched. If you leave out a variable, the default rule applies.

And the label photo?

The label photo is the extra photo of the care or composition label. LABEL_IDENTIFIER works exactly like the other three, with one thing to remember: variables you don't set retain their default. In the example above, LABEL_IDENTIFIER is still set to the word label. Three situations:

  • Your label photo is also numbered Is _PNG_4 the label photo? Set LABEL_IDENTIFIER=_PNG_4$ for it. <EAN>_PNG_1 through _PNG_4 will then come in as one packshot: front, back, side, and label.
  • Your label photo does have a name Is it named, for example, 8712345678906_label.png? Then just leave out LABEL_IDENTIFIER: the default rule on the word label remains active, even if you set the other three to numbers. This way, you can use both methods interchangeably.
  • You don't photograph labels Then you don't need to do anything: photos that don't match any pattern will be skipped. Set LABEL_IDENTIFIER=off only if the word label might accidentally appear in a filename (for example, an item called 'Label Tee') and you don't want to link that photo as a label photo.

off (or none) also works for BACK_IDENTIFIER and SIDE_IDENTIFIER and is the only way to disable a default word. For FRONT_IDENTIFIER, off simply means reverting to the default: the first photo that doesn't belong to any other view.